- up.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent ae) {
- int value = 0;
- try {
- value = Integer.parseInt(field.getText());
- } catch (NumberFormatException e) {
- }
-
- field.setText(Integer.toString(value + 1));
- }
- });
-
- down.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent ae) {
- int value = 0;
- try {
- value = Integer.parseInt(field.getText());
- } catch (NumberFormatException e) {
- }
-
- field.setText(Integer.toString(value - 1));
- }
- });
-
- JPanel upDown = new JPanel(new BorderLayout());
- upDown.add(up, BorderLayout.NORTH);
- upDown.add(down, BorderLayout.SOUTH);
-
- JPanel pane = new JPanel(new BorderLayout());
- pane.add(upDown, BorderLayout.WEST);
- pane.add(field, BorderLayout.CENTER);
-
- this.add(label(info), BorderLayout.WEST);
- this.add(pane, BorderLayout.CENTER);