org.jdesktop.swingx.JXMonthView Java Examples

The following examples show how to use org.jdesktop.swingx.JXMonthView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DatePicker.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEvent(Event event) {
    SwitchLocaleEvent localeEvent = (SwitchLocaleEvent) event;
    setLocale(localeEvent.getLocale());

    todayLink.setText("<html><u>" + Language.I18N.getString("common.label.datePicker.today") + "</u></html>");

    String[] daysOfTheWeek = new String[JXMonthView.DAYS_IN_WEEK];
    String[] dateFormatSymbols = DateFormatSymbols.getInstance(localeEvent.getLocale()).getShortWeekdays();
    for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
        daysOfTheWeek[i - 1] = dateFormatSymbols[i].replaceAll("\\.$", "");
        while (daysOfTheWeek[i - 1].length() < 3)
            daysOfTheWeek[i - 1] = " " + daysOfTheWeek[i - 1];
    }

    getMonthView().setDaysOfTheWeek(daysOfTheWeek);
    getMonthView().setFirstDayOfWeek(Calendar.MONDAY);
    setDate(getDate());
}
 
Example #2
Source File: DateTimePicker.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private void applyUIStyle() {
    JXMonthView monthView = getMonthView();
    monthView.setMonthStringBackground(backgroundColor);
    monthView.setMonthStringForeground(monthForegroundColor);
    monthView.setSelectionBackground(selectionBackgroundColor);
    monthView.setSelectionForeground(selectionForegroundColor);
    monthView.setDaysOfTheWeekForeground(dayOfTheWeekForegroundColor);
    monthView.setBackground(backgroundColor);
    monthView.setForeground(foregroundColor);
    monthView.setTodayBackground(todayBackgroundColor);

    getLinkPanel().setBackground(backgroundColor);
    getLinkPanel().setForeground(foregroundColor);
}
 
Example #3
Source File: DatePickerComboBox.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
public DatePickerComboBox(int preferredHeight, Color backgroundColor, DateFormat dateFormat) {
    super();

    if (preferredHeight <= 0) {
        throw new IllegalArgumentException("The preferred size " + preferredHeight + " must be > 0.");
    }
    if (backgroundColor == null) {
        throw new NullPointerException("The background color is null.");
    }
    if (dateFormat == null) {
        throw new NullPointerException("The date format is null.");
    }

    this.preferredHeight = preferredHeight;
    this.dateFormat = dateFormat;

    setBackground(backgroundColor);
    setBorder(SwingUtils.LINE_BORDER);
    setEditable(true); // set the combo box as editable

    this.monthView = new JXMonthView();
    this.monthView.setTraversable(true);
    this.monthView.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    newSelectedDate();
                }
            });
        }
    });

    Date todayDate = new Date(System.currentTimeMillis());
    String dateAsString = this.dateFormat.format(todayDate);

    JLabel todayLabel = new JLabel("Today is " + dateAsString, JLabel.CENTER);
    Border outsideBorder = new MatteBorder(1, 0, 0, 0, SwingUtils.LINE_BORDER.getLineColor());
    Border insideBorder = new EmptyBorder(5, 0, 5, 0);
    todayLabel.setBorder(new CompoundBorder(outsideBorder, insideBorder));

    this.popup = new JPopupMenu();
    this.popup.setLayout(new BorderLayout());
    this.popup.add(this.monthView, BorderLayout.CENTER);
    this.popup.add(todayLabel, BorderLayout.SOUTH);
    this.popup.setBorder(SwingUtils.LINE_BORDER);

    JComponent editorComponent = getEditorComponent();
    editorComponent.setBorder(null);
    editorComponent.setOpaque(false);
    editorComponent.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            popup.setVisible(false);
        }
    });

    replaceArrowButtonMouseListeners();
}