JXDatePicker extends JComponent { public JFormattedTextField getEditor() { return _dateField; } JXDatePicker();  JXDatePicker(Date selected);  JXDatePicker(Locale locale);  JXDatePicker(Date selection, Locale locale); void setDate(Date date); Date getDate(); DatePickerUI getUI(); void setUI(DatePickerUI ui); @Override void updateUI(); @Override String getUIClassID(); void setFormats(String... formats); void setFormats(DateFormat... formats); DateFormat[] getFormats(); JXMonthView getMonthView(); void setMonthView(JXMonthView monthView); TimeZone getTimeZone(); void setTimeZone(TimeZone tz); Date getLinkDay(); void setLinkDay(Date linkDay, String linkFormatString); void setLinkDay(Date linkDay); JPanel getLinkPanel(); void setLinkPanel(JPanel linkPanel); JFormattedTextField getEditor(); void setEditor(JFormattedTextField editor); @Override void setComponentOrientation(ComponentOrientation orientation); boolean isEditValid(); void commitEdit(); void cancelEdit(); void setEditable(boolean value); boolean isEditable(); @Override Font getFont(); @Override void setFont(final Font font); void setLightWeightPopupEnabled(boolean aFlag); boolean isLightWeightPopupEnabled(); @Override int getBaseline(int width, int height); void addActionListener(ActionListener l); void removeActionListener(ActionListener l); @Override @SuppressWarnings("unchecked") T[] getListeners(Class<T> listenerType); void addPopupMenuListener(PopupMenuListener l); void removePopupMenuListener(PopupMenuListener l); PopupMenuListener[] getPopupMenuListeners(); static final String uiClassID; static final String EDITOR; static final String MONTH_VIEW; static final String LINK_PANEL; static final String COMMIT_KEY; static final String CANCEL_KEY; static final String HOME_NAVIGATE_KEY; static final String HOME_COMMIT_KEY; }
@Test public void testDatePickerColumns50() { JXDatePicker picker = new JXDatePicker(); picker.getEditor().setColumns(50); JXDatePicker other = new JXDatePicker(new Date()); other.getEditor().setColumns(50); assertEquals(other.getEditor().getPreferredSize(), picker.getEditor().getPreferredSize()); }
@Test public void testDatePickerColumns5() { JXDatePicker picker = new JXDatePicker(); picker.getEditor().setColumns(5); JXDatePicker other = new JXDatePicker(new Date()); other.getEditor().setColumns(5); assertEquals(other.getEditor().getPreferredSize(), picker.getEditor().getPreferredSize()); }
@Test public void testPickerBorder() { new JXDatePicker(); Border pickerBorder = UIManager.getBorder("JXDatePicker.border"); if (pickerBorder == null) { LOG.info("cant run test - no pickerborder"); return; } try { UIManager.put("JXDatePicker.border", "none"); assertNull(UIManager.getBorder("JXDatePicker.border")); JXDatePicker picker = new JXDatePicker(); JTextField field = new JFormattedTextField(); assertEquals(field.getBorder(), picker.getEditor().getBorder()); } finally { UIManager.put("JXDatePicker.border", null); assertEquals(pickerBorder, UIManager.getBorder("JXDatePicker.border")); } }
@Test public void testDatePropertyThroughEditor() { JXDatePicker picker = new JXDatePicker(); Date date = XTestUtils.getStartOfToday(5); PropertyChangeReport report = new PropertyChangeReport(); picker.addPropertyChangeListener("date", report); picker.getEditor().setValue(date); TestUtils.assertPropertyChangeEvent(report, "date", null, date); }
@Test public void testSynchAllOnEditorSetValue() { JXDatePicker picker = new JXDatePicker(); Date date = XTestUtils.getStartOfToday(5); picker.getEditor().setValue(date); assertSynchAll(picker, date); }
@Test public void testSpuriousEnabledListening() { JXDatePicker picker = new JXDatePicker(); Component button = null; for (int i = 0; i < picker.getComponentCount(); i++) { if (picker.getComponent(i) instanceof JButton) { button = picker.getComponent(i); } } if (button == null) { LOG.info("cannot run testEnabledListening - no button found"); return; } button.setEnabled(false); assertTrue(picker.isEnabled()); assertTrue(picker.getEditor().isEnabled()); assertFalse("Do not change the state of the sender during notification processing", button.isEnabled()); }
@Test public void testPrefSizeEmptyInsertText() { JXDatePicker picker = new JXDatePicker(); Dimension empty = picker.getPreferredSize(); picker.getEditor().setText("1"); assertEquals("pref width must be same while editing", empty.width, picker.getPreferredSize().width); }
@Test public void testPrefSizeValueInsertText() { JXDatePicker picker = new JXDatePicker(new Date()); Dimension withValue = picker.getPreferredSize(); picker.getEditor().setText("1"); assertEquals("pref width must be same while editing", withValue.width, picker.getPreferredSize().width); }