private void initMonthView() { _monthView = new JXMonthView(); // _monthView.setSelectionModel(new SingleDaySelectionModel()); _monthView.setTraversable(true); _monthView.addPropertyChangeListener(getMonthViewListener()); }
/** * Wires the picker's monthView related listening. Removes all * listeners from the given old view and adds the listeners to * the current monthView. <p> * * @param oldMonthView */ protected void updateMonthViewListeners(JXMonthView oldMonthView) { DateSelectionModel oldModel = null; if (oldMonthView != null) { oldMonthView.removePropertyChangeListener(monthViewPropertyListener); oldMonthView.removeActionListener(monthViewActionListener); oldModel = oldMonthView.getSelectionModel(); } datePicker.getMonthView().addPropertyChangeListener(monthViewPropertyListener); datePicker.getMonthView().addActionListener(monthViewActionListener); updateSelectionModelListeners(oldModel); }
private Border getTitleBorder() { if (monthView.isTraversable()) { IconBorder up = new IconBorder(monthUpImage, SwingConstants.EAST, monthView.getBoxPaddingX()); IconBorder down = new IconBorder(monthDownImage, SwingConstants.WEST, monthView.getBoxPaddingX()); Border compound = BorderFactory.createCompoundBorder(up, down); Border empty = BorderFactory .createEmptyBorder(2 * monthView.getBoxPaddingY(), 0, 2 * monthView.getBoxPaddingY(), 0); return BorderFactory.createCompoundBorder(compound, empty); } return BorderFactory.createEmptyBorder(monthView.getBoxPaddingY(), monthView.getBoxPaddingX(), monthView.getBoxPaddingY(), monthView.getBoxPaddingX()); } }
/** * Sets the number of pixels used to pad the top and bottom of a day. * The padding is applied to both the top and bottom of a day. Therefore, * if you used the padding value of 3, the number of pixels between any * two days would be 6. * * @param boxPaddingY Number of pixels applied to top and bottom of a day */ public void setBoxPaddingY(int boxPaddingY) { int oldBoxPadding = getBoxPaddingY(); this.boxPaddingY = boxPaddingY; firePropertyChange(BOX_PADDING_Y, oldBoxPadding, getBoxPaddingY()); }
/** * Sets the number of pixels used to pad the left and right side of a day. * The padding is applied to both sides of the days. Therefore, if you * used the padding value of 3, the number of pixels between any two days * would be 6. * * @param boxPaddingX Number of pixels applied to both sides of a day */ public void setBoxPaddingX(int boxPaddingX) { int oldBoxPadding = getBoxPaddingX(); this.boxPaddingX = boxPaddingX; firePropertyChange(BOX_PADDING_X, oldBoxPadding, getBoxPaddingX()); }
if (SwingXUtilities.isUIInstallable(monthView.getBackground())) { monthView.setBackground(UIManagerExt.getColor("JXMonthView.background")); if (SwingXUtilities.isUIInstallable(monthView.getForeground())) { monthView.setForeground(UIManagerExt.getColor("JXMonthView.foreground")); if (SwingXUtilities.isUIInstallable(monthView.getFont())) { monthView.setFont(UIManager.getFont("JXMonthView.font")); if (SwingXUtilities.isUIInstallable(monthView.getMonthStringBackground())) { monthView.setMonthStringBackground(UIManagerExt.getColor("JXMonthView.monthStringBackground")); if (SwingXUtilities.isUIInstallable(monthView.getMonthStringForeground())) { monthView.setMonthStringForeground(UIManagerExt.getColor("JXMonthView.monthStringForeground")); if (SwingXUtilities.isUIInstallable(monthView.getDaysOfTheWeekForeground())) { monthView.setDaysOfTheWeekForeground(UIManagerExt.getColor("JXMonthView.daysOfTheWeekForeground")); if (SwingXUtilities.isUIInstallable(monthView.getSelectionBackground())) { monthView.setSelectionBackground(UIManagerExt.getColor("JXMonthView.selectedBackground")); if (SwingXUtilities.isUIInstallable(monthView.getSelectionForeground())) { monthView.setSelectionForeground(UIManagerExt.getColor("JXMonthView.selectedForeground")); if (SwingXUtilities.isUIInstallable(monthView.getFlaggedDayForeground())) { monthView.setFlaggedDayForeground(UIManagerExt.getColor("JXMonthView.flaggedDayForeground")); monthView.setBoxPaddingX(UIManagerExt.getInt("JXMonthView.boxPaddingX"));
protected void installListeners() { propertyChangeListener = createPropertyChangeListener(); mouseListener = createMouseListener(); mouseMotionListener = createMouseMotionListener(); monthView.addPropertyChangeListener(propertyChangeListener); monthView.addMouseListener(mouseListener); monthView.addMouseMotionListener(mouseMotionListener); monthView.getSelectionModel().addDateSelectionListener(getHandler()); }
if (monthView.isShowingWeekNumber()) { dayColumns++; fullBoxHeight = maxBoxHeight; int boxHeight = maxBoxHeight - 2 * monthView.getBoxPaddingY(); fullMonthBoxHeight = Math.max(boxHeight, maxMonthHeight) ; if (monthView.isShowingWeekNumber()) { calendarWidth += fullBoxWidth; Insets insets = monthView.getInsets(); preferredSize.width += insets.left + insets.right; preferredSize.height += insets.top + insets.bottom; getCalendarHeaderHandler().getHeaderComponent().setBounds(getMonthHeaderBounds(monthView.getFirstDisplayedDay(), false));
@Override protected Border getBorder() { if (getComponent() == null) { return super.getBorder(); } if (CalendarState.TITLE == dayState) { return getTitleBorder(); } if (isToday()) { int x = getComponent().getBoxPaddingX(); int y = getComponent().getBoxPaddingY(); Border todayBorder = BorderFactory.createLineBorder(getComponent().getTodayBackground()); Border empty = BorderFactory.createEmptyBorder(y - 1, x - 1, y - 1, x -1); return BorderFactory.createCompoundBorder(todayBorder, empty); } return BorderFactory.createEmptyBorder(getComponent().getBoxPaddingY(), getComponent().getBoxPaddingX(), getComponent().getBoxPaddingY(), getComponent().getBoxPaddingX()); }
/** * Updates date related properties in picker/monthView * after a change in the editor's value. Reverts the * value if the new date is unselectable. * * @param oldDate the editor value before the change * @param newDate the editor value after the change */ protected void updateFromValueChanged(Date oldDate, Date newDate) { if ((newDate != null) && datePicker.getMonthView().isUnselectableDate(newDate)) { revertValue(oldDate); return; } // the other place to interrupt the update spiral if (!CalendarUtils.areEqual(newDate, datePicker.getMonthView().getSelectionDate())) { datePicker.getMonthView().setSelectionDate(newDate); } datePicker.setDate(newDate); }
label.setVisible(formattedTextField.isEnabled() && formattedTextField.isEditable()); monthView = new JXMonthView(); monthView.setTraversable(true); monthView.setShowingLeadingDays(true); monthView.setShowingTrailingDays(true); monthView.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {
UIManager.put(SpinningCalendarHeaderHandler.FOCUSABLE_SPINNER_TEXT, Boolean.TRUE); final JXMonthView monthView = new JXMonthView(); monthView.setZoomable(true); monthView.setLocale(locale); monthView.setFirstDayOfWeek(Calendar.TUESDAY); monthView.setDayForeground(Calendar.TUESDAY, Color.MAGENTA);
/** * Returns the current year of the monthView. Callback for spinner model. * * return the current year of the monthView. */ private int getYear() { Calendar cal = monthView.getCalendar(); return cal.get(Calendar.YEAR); }
this.monthView.addMouseMotionListener(substanceFadeRolloverListener); this.monthView.addMouseListener(substanceFadeRolloverListener); this.monthView.getSelectionModel().addDateSelectionListener( this.substanceFadeSelectionListener);
/** * Sets the editor value to the model's selectedDate. */ private void updateEditorValue() { datePicker.getEditor().setValue(datePicker.getMonthView().getSelectionDate()); }
/** * Create a derived font used to when painting various pieces of the month * view component. This method will be called whenever the font on the * component is set so a new derived font can be created. */ protected Font createDerivedFont() { return monthView.getFont().deriveFont(Font.BOLD); }
/** * @return the selection */ protected SortedSet<Date> getSelection() { return monthView.getSelection(); }
if (SwingXUtilities.isUIInstallable(monthView.getBackground())) { monthView.setBackground(UIManagerExt.getColor("JXMonthView.background")); if (SwingXUtilities.isUIInstallable(monthView.getForeground())) { monthView.setForeground(UIManagerExt.getColor("JXMonthView.foreground")); if (SwingXUtilities.isUIInstallable(monthView.getFont())) { monthView.setFont(UIManager.getFont("JXMonthView.font")); if (SwingXUtilities.isUIInstallable(monthView.getMonthStringBackground())) { monthView.setMonthStringBackground(UIManagerExt.getColor("JXMonthView.monthStringBackground")); if (SwingXUtilities.isUIInstallable(monthView.getMonthStringForeground())) { monthView.setMonthStringForeground(UIManagerExt.getColor("JXMonthView.monthStringForeground")); if (SwingXUtilities.isUIInstallable(monthView.getDaysOfTheWeekForeground())) { monthView.setDaysOfTheWeekForeground(UIManagerExt.getColor("JXMonthView.daysOfTheWeekForeground")); if (SwingXUtilities.isUIInstallable(monthView.getSelectionBackground())) { monthView.setSelectionBackground(UIManagerExt.getColor("JXMonthView.selectedBackground")); if (SwingXUtilities.isUIInstallable(monthView.getSelectionForeground())) { monthView.setSelectionForeground(UIManagerExt.getColor("JXMonthView.selectedForeground")); if (SwingXUtilities.isUIInstallable(monthView.getFlaggedDayForeground())) { monthView.setFlaggedDayForeground(UIManagerExt.getColor("JXMonthView.flaggedDayForeground")); monthView.setBoxPaddingX(UIManagerExt.getInt("JXMonthView.boxPaddingX"));
protected void installListeners() { propertyChangeListener = createPropertyChangeListener(); mouseListener = createMouseListener(); mouseMotionListener = createMouseMotionListener(); monthView.addPropertyChangeListener(propertyChangeListener); monthView.addMouseListener(mouseListener); monthView.addMouseMotionListener(mouseMotionListener); monthView.getSelectionModel().addDateSelectionListener(getHandler()); }
if (monthView.isShowingWeekNumber()) { dayColumns++; fullBoxHeight = maxBoxHeight; int boxHeight = maxBoxHeight - 2 * monthView.getBoxPaddingY(); fullMonthBoxHeight = Math.max(boxHeight, maxMonthHeight) ; if (monthView.isShowingWeekNumber()) { calendarWidth += fullBoxWidth; Insets insets = monthView.getInsets(); preferredSize.width += insets.left + insets.right; preferredSize.height += insets.top + insets.bottom; getCalendarHeaderHandler().getHeaderComponent().setBounds(getMonthHeaderBounds(monthView.getFirstDisplayedDay(), false));