Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在java中创建html js UI GCalendar_Java_User Interface_Calendar - Fatal编程技术网

在java中创建html js UI GCalendar

在java中创建html js UI GCalendar,java,user-interface,calendar,Java,User Interface,Calendar,我正在尝试复制一个类似于gcalendar的UI(只有布局,没有任何功能) 如何用日历构建一个循环来构建这样一个可爱的布局?星期六和节假日都有标记 Thxjava代码: public class CalendarUI { public static String Dias[] = { "", "DOM", "SEG", "TER", "QUA", "QUI", "SEX", "SAB" }; public static String Meses[] = { "JAN", "FEV

我正在尝试复制一个类似于gcalendar的UI(只有布局,没有任何功能) 如何用日历构建一个循环来构建这样一个可爱的布局?星期六和节假日都有标记

Thx

java代码:

public class CalendarUI {
    public static String Dias[] = { "", "DOM", "SEG", "TER", "QUA", "QUI", "SEX", "SAB" };
    public static String Meses[] = { "JAN", "FEV", "MAR", "ABR", "MAI", "JUN", "JUL", "AGO", "SET", "OUT", "NOV", "DEZ" };

    public static void printCalendar(int currMonth){
        int i = 1;      
        Calendar c = Calendar.getInstance();
        NumberFormat formatter = new DecimalFormat("##00");


        c.set(Calendar.YEAR, 2009);
        c.set(Calendar.MONTH, currMonth);
        c.set(Calendar.DATE, i);

        // cabecalho com o mes
        System.out.println(" - " + Meses[currMonth] + " - ");

        // ajuste para o primeiro dia
        for (; i < c.get(Calendar.DAY_OF_WEEK); i++) {
            System.out.print("           ");
        }

        // principal
        for (i = 1; i <= 31; i++) {
            c.set(Calendar.DATE, i);

            if (c.get(Calendar.MONTH) == currMonth) {       
                if (c.get(Calendar.DAY_OF_WEEK) == 1)
                    System.out.println("");

                System.out.print("[ " + Dias[c.get(Calendar.DAY_OF_WEEK)]
                        + ", " + formatter.format(i) + " ]");
            }
        }       

        System.out.println("\n\n");
    }

    public static void main(String[] args) {
        for (int j = 0; j < 12; j++) {
            CalendarUI.printCalendar(j);

        }

    }

你是说像谷歌日历这样的用户界面?See Mark,不完全是,应该像日历上的迭代一样输出它。JTable不符合这一点,我看起来更像是一个算法而不是组件本身。好吧,但评论中确实提到了使用JPanels作为替代方案。您可以使用JPanel,甚至可以自己在Java2D级别绘制组件。现在,基本上,更改打印标记,就可以为UI输出正确的html。
 - MAI - 
                                                       [ SEX, 01 ][ SAB, 02 ]
[ DOM, 03 ][ SEG, 04 ][ TER, 05 ][ QUA, 06 ][ QUI, 07 ][ SEX, 08 ][ SAB, 09 ]
[ DOM, 10 ][ SEG, 11 ][ TER, 12 ][ QUA, 13 ][ QUI, 14 ][ SEX, 15 ][ SAB, 16 ]
[ DOM, 17 ][ SEG, 18 ][ TER, 19 ][ QUA, 20 ][ QUI, 21 ][ SEX, 22 ][ SAB, 23 ]
[ DOM, 24 ][ SEG, 25 ][ TER, 26 ][ QUA, 27 ][ QUI, 28 ][ SEX, 29 ][ SAB, 30 ]
[ DOM, 31 ]