本文整理汇总了Java中org.jdesktop.swingx.event.DateSelectionEvent类的典型用法代码示例。如果您正苦于以下问题:Java DateSelectionEvent类的具体用法?Java DateSelectionEvent怎么用?Java DateSelectionEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DateSelectionEvent类属于org.jdesktop.swingx.event包,在下文中一共展示了DateSelectionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAdjusting
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
/**
* adding api: adjusting.
*
*/
@Test
public void testAdjusting() {
// default value
assertFalse(model.isAdjusting());
DateSelectionReport report = new DateSelectionReport(model);
// set adjusting
model.setAdjusting(true);
assertTrue("model must be adjusting", model.isAdjusting());
assertEquals(1, report.getEventCount());
assertEquals(DateSelectionEvent.EventType.ADJUSTING_STARTED,
report.getLastEventType());
// next round - reset to default adjusting
report.clear();
model.setAdjusting(false);
assertFalse("model must not be adjusting", model.isAdjusting());
assertEquals(1, report.getEventCount());
assertEquals(DateSelectionEvent.EventType.ADJUSTING_STOPPED,
report.getLastEventType());
}
示例2: testDateSelectionClearSelectionFireIfSelected
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
/**
* related to #625-swingx: DateSelectionModel must fire SELECTION_CLEARED if
* had selection.
* Testing here for sanity reasons ... be sure we didn't prevent the firing
* altogether while changing.
*/
@Test
public void testDateSelectionClearSelectionFireIfSelected() {
Date date = new Date();
model.setSelectionInterval(date, date);
// sanity
assertFalse(model.isSelectionEmpty());
DateSelectionReport report = new DateSelectionReport(model);
model.clearSelection();
assertEquals("selection must fire on clearing selection",
1,
report.getEventCount());
assertEquals("event type must be SELECTION_CLEARED",
DateSelectionEvent.EventType.SELECTION_CLEARED,
report.getLastEventType());
}
示例3: testDateSelectionSetSelectionFire
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
/**
* related to #625-swingx: DateSelectionModel must fire SELECTION_CLEARED if
* had selection.
* Testing here for sanity reasons ... be sure we didn't prevent the firing
* altogether while changing.
*/
@Test
public void testDateSelectionSetSelectionFire() {
Date date = new Date();
model.setSelectionInterval(date, date);
// sanity
assertTrue(model.isSelected(date));
DateSelectionReport report = new DateSelectionReport(model);
// modify the date
calendar.setTime(date);
calendar.add(Calendar.HOUR, 1);
model.setSelectionInterval(calendar.getTime(), calendar.getTime());
assertEquals("selection must fire on selection",
1,
report.getEventCount());
assertEquals("event type must be DATES_SET",
DateSelectionEvent.EventType.DATES_SET,
report.getLastEventType());
}
示例4: assertUnselectableDatesSelectedWhileHasValidSelection
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
/**
* @param model
*/
private void assertUnselectableDatesSelectedWhileHasValidSelection(
DateSelectionModel model) {
SortedSet<Date> unselectableDates = new TreeSet<Date>();
unselectableDates.add(tomorrow);
model.setUnselectableDates(unselectableDates);
// valid selection
model.setSelectionInterval(today, today);
DateSelectionReport report = new DateSelectionReport(model);
model.setSelectionInterval(tomorrow, tomorrow);
if (model.isSelectionEmpty()) {
assertEquals("implementation clears old selection, must fire clear event",
1, report.getEventCount(DateSelectionEvent.EventType.SELECTION_CLEARED));
} else {
assertEquals("implementation does not clear old selection, old must be unchanged",
today, model.getSelection().first());
}
}
示例5: testDateSelectionSetSelectionFire
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
/**
* related to #625-swingx: DateSelectionModel must fire SELECTION_CLEARED if
* had selection.
* Testing here for sanity reasons ... be sure we didn't prevent the firing
* altogether while changing.
*/
@Test
public void testDateSelectionSetSelectionFire() {
model.setSelectionInterval(today, today);
// sanity
assertTrue(model.isSelected(today));
DateSelectionReport report = new DateSelectionReport(model);
model.setSelectionInterval(tomorrow, tomorrow);
assertEquals("selection must fire on selection",
1,
report.getEventCount());
assertEquals("event type must be DATES_SET",
DateSelectionEvent.EventType.DATES_SET,
report.getLastEventType());
}
示例6: testEventImmutable
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
/**
* Event properties should be immutable.
*
*/
@Test
public void testEventImmutable() {
DateSelectionReport report = new DateSelectionReport(model);
Date date = new Date();
model.setSelectionInterval(date, date);
assertEquals(1, report.getEventCount());
DateSelectionEvent event = report.getLastEvent();
// sanity
assertEquals(date, event.getSelection().first());
Date next = new Date();
model.setSelectionInterval(next, next);
assertSame(date, event.getSelection().first());
}
示例7: hasEvent
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
public boolean hasEvent(EventType type) {
for (DateSelectionEvent ev : events) {
if (ev.getEventType().equals(type)) {
return true;
}
}
return false;
}
示例8: getEventCount
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
public int getEventCount(EventType type) {
int count = 0;
for (DateSelectionEvent ev : events) {
if (ev.getEventType().equals(type)) {
count++;
}
}
return count;
}
示例9: valueChanged
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
@Override
public void valueChanged(DateSelectionEvent ev) {
monthView.repaint();
}
示例10: valueChanged
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
@Override
public void valueChanged(DateSelectionEvent ev) {
updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
}
示例11: interactiveMonthViewEvents
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
/**
* Issue #??-swingx: esc/enter does not always fire actionEvent.
*
* Fixed: committing/canceling user gestures always fire.
*
* Open: mouse-gestures?
*
*/
public void interactiveMonthViewEvents() {
JXMonthView monthView = new JXMonthView();
JXMonthView interval = new JXMonthView();
interval.setSelectionMode(SelectionMode.SINGLE_INTERVAL_SELECTION);
JXMonthView multiple = new JXMonthView();
multiple.setSelectionMode(SelectionMode.MULTIPLE_INTERVAL_SELECTION);
ActionListener l = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
LOG.info("got action from: " + e.getSource().getClass().getName() +
"\n" + e);
}
};
monthView.addActionListener(l);
interval.addActionListener(l);
multiple.addActionListener(l);
DateSelectionListener d = new DateSelectionListener() {
@Override
public void valueChanged(DateSelectionEvent ev) {
LOG.info("got selection from: " + ev.getSource().getClass().getName() +
"\n" + ev);
}
};
monthView.getSelectionModel().addDateSelectionListener(d);
interval.getSelectionModel().addDateSelectionListener(d);
multiple.getSelectionModel().addDateSelectionListener(d);
JXDatePicker picker = new JXDatePicker();
JXMonthView intervalForPicker = new JXMonthView();
intervalForPicker.setSelectionMode(SelectionMode.SINGLE_INTERVAL_SELECTION);
// JW: this picker comes up with today - should have taken the
// empty selection (which it does the unit test)
picker.setMonthView(intervalForPicker);
JComponent comp = new JPanel();
comp.add(monthView);
comp.add(interval);
comp.add(multiple);
comp.add(picker);
JXFrame frame = showInFrame(comp, "events from monthView");
// JXRootPane eats esc
frame.getRootPaneExt().getActionMap().remove("esc-action");
}
示例12: valueChanged
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
public void valueChanged(DateSelectionEvent evt) {
events.add(0, evt);
}
示例13: getLastEvent
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
public DateSelectionEvent getLastEvent() {
return hasEvents() ? events.get(0) : null;
}
示例14: valueChanged
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
public void valueChanged(DateSelectionEvent ev) {
monthView.repaint();
}
示例15: valueChanged
import org.jdesktop.swingx.event.DateSelectionEvent; //导入依赖的package包/类
public void valueChanged(DateSelectionEvent ev) {
updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting());
}