Java Code Examples for org.jdesktop.swingx.JXDatePicker#setFormats()
The following examples show how to use
org.jdesktop.swingx.JXDatePicker#setFormats() .
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: ExportActionListener.java From collect-earth with MIT License | 6 votes |
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; } }
Example 2
Source File: DateComponent.java From software-demo with MIT License | 5 votes |
/** * 使用JXDatePicker创建日期选择器 * @param date * @return */ public JXDatePicker getJXDatePicker (Date date){ final JXDatePicker datepick = new JXDatePicker(); // 设置 date日期 datepick.setDate(date); //设置日期格式 String DefaultFormat = "yyyy-MM-dd"; datepick.setFormats(new SimpleDateFormat(DefaultFormat)); //设置字体 Font font = new Font("Times New Roman", Font.BOLD, 14); datepick.setFont(font); //用setBounds()直接设置大小与位置 datepick.setBounds(this.x, this.y, this.width, this.height); return datepick; }
Example 3
Source File: EditTimeSpanAction.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private JXDatePicker createDateComboBox() { TimeZone utcZone = TimeZone.getTimeZone("UTC"); Calendar utc = Calendar.getInstance(utcZone); Date date = utc.getTime(); JXDatePicker datePicker = new JXDatePicker(date); datePicker.setTimeZone(utcZone); datePicker.setFormats(dateFormat); return datePicker; }
Example 4
Source File: UIUtil.java From ganttproject with GNU General Public License v3.0 | 4 votes |
public static JXDatePicker createDatePicker(DateFormat... dateFormats) { final JXDatePicker result = new JXDatePicker(); result.setLocale(GanttLanguage.getInstance().getDateFormatLocale()); result.setFormats(dateFormats); return result; }
Example 5
Source File: TimeRangeFilter.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
public TimeRangeFilter(final JCheckBox filterCheckBox) { this.filterCheckBox = filterCheckBox; final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Calendar utc = Calendar.getInstance(TimeZone.getTimeZone("UTC")); Date date = utc.getTime(); startDateButton = new JXDatePicker(date); startDateButton.setFormats(dateFormat); stopDateButton = new JXDatePicker(date); stopDateButton.setFormats(dateFormat); final int width = 150; final Dimension ps = startDateButton.getPreferredSize(); final Dimension comboBoxDimension = new Dimension(width, ps.height); setJComponentSize(comboBoxDimension, startDateButton); setJComponentSize(comboBoxDimension, stopDateButton); datePatternComboBox = new JComboBox<>(); setJComponentSize(comboBoxDimension, datePatternComboBox); datePatternComboBox.setEditable(true); fileNamePatternComboBox = new JComboBox<>(); setJComponentSize(comboBoxDimension, fileNamePatternComboBox); fileNamePatternComboBox.setEditable(true); initPatterns(); final UIUpdater uiUpdater = new UIUpdater(); filterCheckBox.addActionListener(e -> { updateUIState(); if (timeStampExtractor != null) { fireFilterChangedEvent(); } }); startDateButton.addPropertyChangeListener(DateTimePicker.COMMIT_KEY, evt -> updateUIState()); startDateButton.addPropertyChangeListener(DateTimePicker.COMMIT_KEY, evt -> validateDateChooser(startDateButton)); stopDateButton.addPropertyChangeListener(DateTimePicker.COMMIT_KEY, evt -> updateUIState()); stopDateButton.addPropertyChangeListener(DateTimePicker.COMMIT_KEY, evt -> validateDateChooser(stopDateButton)); datePatternComboBox.addActionListener(uiUpdater); fileNamePatternComboBox.addActionListener(uiUpdater); listeners = new ArrayList<>(); labels = new ArrayList<>(); applyButton = new JButton("Apply"); applyButton.addActionListener(e -> { if (StringUtils.isNotNullAndNotEmpty(datePatternComboBox.getEditor().getItem().toString()) && StringUtils.isNotNullAndNotEmpty(fileNamePatternComboBox.getEditor().getItem().toString())) { timeStampExtractor = new TimeStampExtractor(datePatternComboBox.getSelectedItem().toString(), fileNamePatternComboBox.getSelectedItem().toString()); } else { timeStampExtractor = null; } startDate = startDateButton.getDate(); endDate = stopDateButton.getDate(); updateUIState(); applyButton.setEnabled(false); fireFilterChangedEvent(); }); }