本文整理汇总了Java中org.jdesktop.swingx.JXDatePicker类的典型用法代码示例。如果您正苦于以下问题:Java JXDatePicker类的具体用法?Java JXDatePicker怎么用?Java JXDatePicker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JXDatePicker类属于org.jdesktop.swingx包,在下文中一共展示了JXDatePicker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPickDateDlg
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
private Date getPickDateDlg() {
JPanel panel = new JPanel();
JXDatePicker picker = new JXDatePicker();
picker.setDate(Calendar.getInstance().getTime());
picker.setFormats(new SimpleDateFormat("dd.MM.yyyy")); //$NON-NLS-1$
panel.add(picker);
int result = JOptionPane.showConfirmDialog(frame,
panel,
Messages.getString("ExportActionListener.1"), //$NON-NLS-1$
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE);
if( result == JOptionPane.OK_OPTION ){
return picker.getDate();
}else{
return null;
}
}
示例2: MarketDataSpecificationComponent
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
public MarketDataSpecificationComponent(List<LiveDataMetaDataProvider> metaDataProviders, ConfigMaster configMaster, MarketDataSnapshotMaster snapshotMaster) {
super();
_configMaster = configMaster;
_snapshotMaster = snapshotMaster;
_metaDataProviders = metaDataProviders;
_dataSourceTypeCombo = createDataSourceTypeCombo();
_dataSourceCombo = createDataSourceCombo();
_snapshotVersionCombo = createSnapshotVersionCombo();
_datePicker = new JXDatePicker();
_datePicker.setPreferredSize(SNAPSHOT_VERSION_PREFERRED_SIZE);
_datePicker.setMinimumSize(SNAPSHOT_VERSION_PREFERRED_SIZE);
_datePicker.setMaximumSize(SNAPSHOT_VERSION_PREFERRED_SIZE);
createModels();
addComponents();
setPreferredSize(COMPONENT_PREFERRED_SIZE);
}
示例3: DatePickerCellEditor
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
/**
* Instantiates an editor with the given dateFormat. If
* null, the datePickers default is used.
*
* @param dateFormat
*/
public DatePickerCellEditor(DateFormat dateFormat) {
// JW: the copy is used to synchronize .. can
// we use something else?
this.dateFormat = dateFormat != null ? dateFormat :
DateFormat.getDateInstance();
datePicker = new JXDatePicker();
// default border crushes the editor/combo
datePicker.getEditor().setBorder(
BorderFactory.createEmptyBorder(0, 1, 0, 1));
// should be fixed by j2se 6.0
datePicker.setFont(UIManager.getDefaults().getFont("TextField.font"));
if (dateFormat != null) {
datePicker.setFormats(dateFormat);
}
datePicker.addActionListener(getPickerActionListener());
}
示例4: installKeyboardActions
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
protected void installKeyboardActions() {
// install picker's actions
ActionMap pickerMap = datePicker.getActionMap();
pickerMap.put(JXDatePicker.CANCEL_KEY, createCancelAction());
pickerMap.put(JXDatePicker.COMMIT_KEY, createCommitAction());
pickerMap.put(JXDatePicker.HOME_NAVIGATE_KEY, createHomeAction(false));
pickerMap.put(JXDatePicker.HOME_COMMIT_KEY, createHomeAction(true));
TogglePopupAction popupAction = createTogglePopupAction();
pickerMap.put("TOGGLE_POPUP", popupAction);
InputMap pickerInputMap = datePicker.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
pickerInputMap.put(KeyStroke.getKeyStroke("ENTER"), JXDatePicker.COMMIT_KEY);
pickerInputMap.put(KeyStroke.getKeyStroke("ESCAPE"), JXDatePicker.CANCEL_KEY);
// PENDING: get from LF
pickerInputMap.put(KeyStroke.getKeyStroke("F5"), JXDatePicker.HOME_COMMIT_KEY);
pickerInputMap.put(KeyStroke.getKeyStroke("shift F5"), JXDatePicker.HOME_NAVIGATE_KEY);
pickerInputMap.put(KeyStroke.getKeyStroke("alt DOWN"), "TOGGLE_POPUP");
installLinkPanelKeyboardActions();
}
示例5: installLinkPanelKeyboardActions
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
/**
* Installs actions and key bindings on the datePicker's linkPanel. Does
* nothing if the linkPanel is null.
*
* PRE: keybindings installed on picker.
*/
protected void installLinkPanelKeyboardActions() {
if (datePicker.getLinkPanel() == null)
return;
ActionMap map = datePicker.getLinkPanel().getActionMap();
map.put(JXDatePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get(
JXDatePicker.HOME_COMMIT_KEY));
map.put(JXDatePicker.HOME_NAVIGATE_KEY, datePicker.getActionMap().get(
JXDatePicker.HOME_NAVIGATE_KEY));
InputMap inputMap = datePicker.getLinkPanel().getInputMap(
JComponent.WHEN_IN_FOCUSED_WINDOW);
// PENDING: get from LF
inputMap.put(KeyStroke.getKeyStroke("F5"),
JXDatePicker.HOME_COMMIT_KEY);
inputMap.put(KeyStroke.getKeyStroke("shift F5"),
JXDatePicker.HOME_NAVIGATE_KEY);
}
示例6: testFocusedInitialTrue
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
@Test
public void testFocusedInitialTrue() throws InterruptedException, InvocationTargetException {
// This test will not work in a headless configuration.
if (GraphicsEnvironment.isHeadless()) {
LOG.fine("cannot run test - headless environment");
return;
}
final JXDatePicker picker = getRealizedDatePicker();
picker.requestFocusInWindow();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
assertTrue("sanity: focus transfered into picker hierarchy",
SwingXUtilities.isDescendingFrom(focusOwner, picker));
CompoundFocusListener l = new CompoundFocusListener(picker);
assertTrue("listener must take initial focused state ", l.isFocused());
}
});
}
示例7: testRelease
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
/**
* Test no property change fired after release.
*
* @throws InterruptedException
* @throws InvocationTargetException
*/
@Test
public void testRelease() throws InterruptedException, InvocationTargetException {
// This test will not work in a headless configuration.
if (GraphicsEnvironment.isHeadless()) {
LOG.fine("cannot run test - headless environment");
return;
}
JXDatePicker picker = getRealizedDatePicker();
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
assertFalse("sanity: initial focus must not be in picker",
SwingXUtilities.isDescendingFrom(focusOwner, picker));
CompoundFocusListener l = new CompoundFocusListener(picker);
final PropertyChangeReport report = new PropertyChangeReport();
l.addPropertyChangeListener(report);
l.release();
picker.requestFocusInWindow();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
assertEquals(0, report.getEventCount("focused"));
}
});
}
示例8: testFireFocusedProperty
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
/**
* Test property change fired on focusGained.
*
* @throws InterruptedException
* @throws InvocationTargetException
*/
@Test
public void testFireFocusedProperty() throws InterruptedException, InvocationTargetException {
// This test will not work in a headless configuration.
if (GraphicsEnvironment.isHeadless()) {
LOG.fine("cannot run test - headless environment");
return;
}
JXDatePicker picker = getRealizedDatePicker();
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
assertFalse("sanity: initial focus must not be in picker",
SwingXUtilities.isDescendingFrom(focusOwner, picker));
CompoundFocusListener l = new CompoundFocusListener(picker);
final PropertyChangeReport report = new PropertyChangeReport();
l.addPropertyChangeListener(report);
picker.requestFocusInWindow();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
assertEquals(1, report.getEventCount("focused"));
}
});
}
示例9: interactiveDatePickerCellEditorXTable
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
/**
* Issue ??-swingx: picker cell editor popup commit/cancel
* transfers focus out-off the table (1.5)
*
* Looks like a core issue - editable combo misbehaves as well.
* Here we use a JXTable.
*/
public void interactiveDatePickerCellEditorXTable() {
final JXTable table = new JXTable(createTableModel(2));
table.setVisibleColumnCount(6);
// table.setSurrendersFocusOnKeystroke(true);
installEditors(table);
Action action = new AbstractAction("toggle terminate") {
public void actionPerformed(ActionEvent e) {
table.setTerminateEditOnFocusLost(!table.isTerminateEditOnFocusLost());
}
};
JXFrame frame = wrapWithScrollingInFrame(table, "JXTable - date picker cell editor");
addAction(frame, action);
frame.add(new JXDatePicker(), BorderLayout.SOUTH);
show(frame);
}
示例10: doDatePickerAction
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
private static void doDatePickerAction(TestStep step) throws HeadlessException {
int componentId = step.getComponent();
TestStep.Action action = step.getAction();
JXDatePicker datePicker = bankAppStarter.retrieveComponent(componentId, JXDatePicker.class);
switch (action.getName()) {
case PICK_DATE:
sleep(step.getPreWait());
Date date = Calendar.getInstance().getTime();
try {
date = parseString2Date(action.getParameter());
} catch (ParseException ex) {
exitWithErr(new StringBuilder("Illegal parameter setting in DatePicker PickDate action, it must be yyyy-MM-dd. ")
.append(" with component ID ")
.append(componentId).toString());
}
datePicker.setDate(date);
sleep(step.getPostWait());
break;
default:
exitWithErr(new StringBuilder("Unsupported DatePicker action ")
.append(action.getName())
.append(" with component ID ")
.append(componentId).toString());
}
}
示例11: retrieveNumber
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
protected long retrieveNumber(int componentID) {
long value = Long.MIN_VALUE;
king.flow.view.Component meta = (king.flow.view.Component) getBlockMeta(componentID);
ComponentEnum type = meta.getType();
switch (type) {
case DATE:
JXDatePicker jdp = getBlock(componentID, JXDatePicker.class);
Date date = jdp.getDate();
value = date.getTime();
break;
case TEXT_FIELD:
JTextField jtf = getBlock(componentID, JTextField.class);
String text = jtf.getText();
try {
value = Long.parseLong(text);
} catch (NumberFormatException e) {
CommonUtil.getLogger(DefaultAction.class.getName()).log(Level.WARNING,
"Invalidated textfiled numeric value", e);
}
break;
default:
CommonUtil.getLogger(DefaultAction.class.getName()).log(Level.INFO,
"Unsupported more-less-comparing component type : {0}", type);
}
return value;
}
示例12: buildStartDatePicker
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
private JXDatePicker buildStartDatePicker() {
startDatePicker = buildDatePicker(resourceManager.getString("start.date"));
startDatePicker.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (dateRangeList.isNotEmpty()) {
Date startDate = startDatePicker.getDate();
DateRange dateRange = dateRangeList.getSelectedEntity();
try {
dateRange.setStartDate(startDate);
} catch (IllegalArgumentException e) {
showDatePickerErrorMessage(startDatePicker, e);
}
}
}
});
return startDatePicker;
}
示例13: buildEndDatePicker
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
private JXDatePicker buildEndDatePicker() {
endDatePicker = buildDatePicker(resourceManager.getString("end.date"));
endDatePicker.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (dateRangeList.isNotEmpty()) {
Date endDate = endDatePicker.getDate();
DateRange dateRange = dateRangeList.getSelectedEntity();
try {
dateRange.setEndDate(endDate);
} catch (IllegalArgumentException e) {
showDatePickerErrorMessage(endDatePicker, e);
}
}
}
});
return endDatePicker;
}
示例14: validateDateChooser
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
private void validateDateChooser(JXDatePicker button) {
Date startDate = startDateButton.getDate();
Date endDate = stopDateButton.getDate();
if (startDate == null || endDate == null) {
return;
}
if (startDate.after(endDate)) {
if (button.equals(startDateButton)) {
startDateButton.setDate(endDate);
LOG.info("Start date after end date: Set start date to end date.");
} else if (button.equals(stopDateButton)) {
stopDateButton.setDate(startDate);
LOG.info("Start date after end date: Set end date to start date.");
}
}
}
示例15: installKeyboardActions
import org.jdesktop.swingx.JXDatePicker; //导入依赖的package包/类
@Override
protected void installKeyboardActions() {
super.installKeyboardActions();
ActionMap pickerMap = datePicker.getActionMap();
pickerMap.remove(JXDatePicker.CANCEL_KEY);
InputMap pickerInputMap = datePicker.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
pickerInputMap.remove(KeyStroke.getKeyStroke("ESCAPE"));
}