use of javax.swing.SpinnerListModel in project keystore-explorer by kaikramer.
the class DDateTimeChooser method initComponents.
private void initComponents(Date date) {
jcbMonth = new JComboBox<Object>(MONTH_NAMES);
jcbMonth.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent evt) {
update();
}
});
jsYear = new JSpinner(new SpinnerListModel(YEARS));
jsYear.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent evt) {
update();
}
});
jlDaysOfMonth = new JLabel[7][7];
for (int i = 0; i < 7; i++) {
jlDaysOfMonth[0][i] = new JLabel(DAY_NAMES[i], SwingConstants.RIGHT);
jlDaysOfMonth[0][i].setOpaque(true);
jlDaysOfMonth[0][i].setForeground(WEEK_DAY_FOREGROUND);
jlDaysOfMonth[0][i].setBackground(WEEK_DAY_BACKGROUND);
jlDaysOfMonth[0][i].setBorder(new EmptyBorder(0, 0, 0, 3));
}
for (int i = 1; i < 7; i++) {
for (int j = 0; j < 7; j++) {
jlDaysOfMonth[i][j] = new JLabel(EMPTY_DAY, SwingConstants.RIGHT);
jlDaysOfMonth[i][j].setOpaque(true);
jlDaysOfMonth[i][j].setForeground(DAY_FOREGROUND);
jlDaysOfMonth[i][j].setBackground(DAY_BACKGROUND);
jlDaysOfMonth[i][j].addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
selectDay((JLabel) evt.getSource());
}
});
jlDaysOfMonth[i][j].setBorder(new CompoundBorder(new MatteBorder(2, 0, 0, 0, Color.WHITE), new EmptyBorder(0, 0, 0, 3)));
}
}
jpMonthYear = new JPanel();
jpMonthYear.add(jcbMonth);
jpMonthYear.add(jsYear);
jpDaysOfMonth = new JPanel(new DayOfMonthGridLayout(7, 7));
jpDaysOfMonth.setBackground(DAY_BACKGROUND);
jpDaysOfMonth.setBorder(new CompoundBorder(BorderFactory.createLoweredBevelBorder(), new EmptyBorder(2, 2, 2, 2)));
jpDaysOfMonth.setFocusable(true);
jpDaysOfMonth.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent evt) {
setSelectedDay(jlSelectedDayOfMonth);
}
@Override
public void focusLost(FocusEvent evt) {
setSelectedDay(jlSelectedDayOfMonth);
}
});
jpDaysOfMonth.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent evt) {
calendarKeyboardNavigation(evt);
}
});
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 7; j++) {
jpDaysOfMonth.add(jlDaysOfMonth[i][j]);
}
}
jsHour = new JSpinner(new SpinnerListModel(HOURS));
jlTimeSeparator1 = new JLabel(":");
jsMinute = new JSpinner(new SpinnerListModel(MINUTES));
jlTimeSeparator2 = new JLabel(":");
jsSecond = new JSpinner(new SpinnerListModel(SECONDS));
jpTime = new JPanel(new FlowLayout(FlowLayout.CENTER));
jpTime.add(jsHour);
jpTime.add(jlTimeSeparator1);
jpTime.add(jsMinute);
jpTime.add(jlTimeSeparator2);
jpTime.add(jsSecond);
JPanel jpDateTime = new JPanel(new BorderLayout(0, 0));
jpDateTime.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
jpDateTime.add(BorderLayout.NORTH, jpMonthYear);
jpDateTime.add(BorderLayout.CENTER, jpDaysOfMonth);
jpDateTime.add(BorderLayout.SOUTH, jpTime);
jbOK = new JButton(res.getString("DDateTimeChooser.jbOK.text"));
jbOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
okPressed();
}
});
jbCancel = new JButton(res.getString("DDateTimeChooser.jbCancel.text"));
jbCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent evt) {
cancelPressed();
}
});
jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(BorderLayout.CENTER, jpDateTime);
getContentPane().add(BorderLayout.SOUTH, jpButtons);
if (date == null) {
date = new Date();
}
populate(date);
setResizable(false);
getRootPane().setDefaultButton(jbOK);
pack();
}
use of javax.swing.SpinnerListModel in project opennars by opennars.
the class CharacterEditor method buildModel.
protected void buildModel(char min, char max) {
List<Character> characters = new ArrayList<Character>();
for (char c = min; c <= max; c++) {
characters.add(c);
}
spinner.setModel(new SpinnerListModel(characters));
}
Aggregations