예제 #1
0
    private void createYearAndMonthPanal() {
      Calendar c = getNowCalendar();
      int currentYear = c.get(Calendar.YEAR);
      int currentMonth = c.get(Calendar.MONTH) + 1;
      int currentHour = c.get(Calendar.HOUR_OF_DAY);
      yearSpin =
          new JSpinner(new javax.swing.SpinnerNumberModel(currentYear, startYear, lastYear, 1));
      monthSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentMonth, 1, 12, 1));
      hourSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentHour, 0, 23, 1));

      yearPanel.setLayout(new java.awt.FlowLayout());
      yearPanel.setBackground(controlLineColor);

      yearSpin.setPreferredSize(new Dimension(48, 20));
      yearSpin.setName("Year");
      yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
      yearSpin.addChangeListener(this);
      yearPanel.add(yearSpin);

      JLabel yearLabel = new JLabel("年");
      yearLabel.setForeground(controlTextColor);
      yearPanel.add(yearLabel);

      monthSpin.setPreferredSize(new Dimension(35, 20));
      monthSpin.setName("Month");
      monthSpin.addChangeListener(this);
      yearPanel.add(monthSpin);

      JLabel monthLabel = new JLabel("月");
      monthLabel.setForeground(controlTextColor);
      yearPanel.add(monthLabel);

      hourSpin.setPreferredSize(new Dimension(35, 20));
      hourSpin.setName("Hour");
      hourSpin.addChangeListener(this);
      yearPanel.add(hourSpin);

      JLabel hourLabel = new JLabel("日");
      hourLabel.setForeground(controlTextColor);
      yearPanel.add(hourLabel);
    }