use of com.github.lgooddatepicker.zinternaltools.DateTimeChangeEvent in project sldeditor by robward-scisys.
the class DateTimePanel method createUI.
/**
* Creates the UI.
*
* @param xPos the x pos
* @param indentWidth the indent width
* @param yOffset the y offset
* @param fieldPanel the field panel
*/
public void createUI(int xPos, int indentWidth, int yOffset, JPanel fieldPanel) {
if (dateTimePicker == null) {
DatePickerSettings dateModel = new DatePickerSettings();
dateModel.setAllowEmptyDates(false);
dateModel.setFormatForDatesCommonEra(DateTimeFormatter.ofPattern("dd MMM yyyy"));
TimePickerSettings timeModel = new TimePickerSettings();
timeModel.setAllowEmptyTimes(false);
timeModel.setDisplaySpinnerButtons(true);
timeModel.setDisplayToggleTimeMenuButton(false);
timeModel.setFormatForDisplayTime(PickerUtilities.createFormatterFromPatternString("HH:mm:ss.SSS", timeModel.getLocale()));
dateTimePicker = new DateTimePicker(dateModel, timeModel);
int x = xPos + indentWidth;
dateTimePicker.setBounds(x, yOffset, DATEPICKER_WIDTH, BasePanel.WIDGET_HEIGHT);
fieldPanel.add(dateTimePicker);
offsetSign = new JComboBox<>(offsetStrings);
int y = BasePanel.WIDGET_HEIGHT + yOffset;
offsetSign.setBounds(x, y, OFFSET_SIGN_WIDTH, BasePanel.WIDGET_HEIGHT);
offsetSign.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (callback != null) {
callback.dateTimeValueUpdated();
}
}
});
fieldPanel.add(offsetSign);
SpinnerNumberModel hourModel = new SpinnerNumberModel();
hourModel.setStepSize(1);
hourModel.setMinimum(0);
hourModel.setMaximum(23);
hourSpinner = new JSpinner(hourModel);
hourSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (callback != null) {
callback.dateTimeValueUpdated();
}
}
});
fieldPanel.add(hourSpinner);
x += OFFSET_SIGN_WIDTH + 2;
hourSpinner.setBounds(x, y, OFFSET_HOURS_WIDTH, BasePanel.WIDGET_HEIGHT);
SpinnerNumberModel secondModel = new SpinnerNumberModel();
secondModel.setStepSize(1);
secondModel.setMinimum(0);
secondModel.setMaximum(59);
minuteSpinner = new JSpinner(secondModel);
fieldPanel.add(minuteSpinner);
minuteSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (callback != null) {
callback.dateTimeValueUpdated();
}
}
});
x += OFFSET_HOURS_WIDTH + 2;
minuteSpinner.setBounds(x, y, OFFSET_MINUTES_WIDTH, BasePanel.WIDGET_HEIGHT);
dateTimePicker.addDateTimeChangeListener(new DateTimeChangeListener() {
@Override
public void dateOrTimeChanged(DateTimeChangeEvent event) {
if (callback != null) {
callback.dateTimeValueUpdated();
}
}
});
}
}
Aggregations