/** * Receives notification of mouse clicks. * * @param e the mouse event. */ public void mouseClicked(final MouseEvent e) { if (e.getSource() == this.upButton) { this.value++; this.textField.setText(Integer.toString(this.value)); firePropertyChange("value", this.value - 1, this.value); } else if (e.getSource() == this.downButton) { this.value--; this.textField.setText(Integer.toString(this.value)); firePropertyChange("value", this.value + 1, this.value); } }
/** * Creates a new spinner. * * @param value the initial value. */ public Spinner(final int value) { super(new BorderLayout()); this.value = value; this.textField = new JTextField(Integer.toString(this.value)); this.textField.setHorizontalAlignment(SwingConstants.RIGHT); add(this.textField); this.buttonPanel = new JPanel(new GridLayout(2, 1, 0, 1)); this.upButton = new ArrowPanel(ArrowPanel.UP); this.upButton.addMouseListener(this); this.downButton = new ArrowPanel(ArrowPanel.DOWN); this.downButton.addMouseListener(this); this.buttonPanel.add(this.upButton); this.buttonPanel.add(this.downButton); add(this.buttonPanel, BorderLayout.EAST); }
/** * Creates a new spinner. * * @param value the initial value. */ public Spinner(final int value) { super(new BorderLayout()); this.value = value; this.textField = new JTextField(Integer.toString(this.value)); this.textField.setHorizontalAlignment(SwingConstants.RIGHT); add(this.textField); this.buttonPanel = new JPanel(new GridLayout(2, 1, 0, 1)); this.upButton = new ArrowPanel(ArrowPanel.UP); this.upButton.addMouseListener(this); this.downButton = new ArrowPanel(ArrowPanel.DOWN); this.downButton.addMouseListener(this); this.buttonPanel.add(this.upButton); this.buttonPanel.add(this.downButton); add(this.buttonPanel, BorderLayout.EAST); }
/** * Receives notification of mouse clicks. * * @param e the mouse event. */ public void mouseClicked(final MouseEvent e) { if (e.getSource() == this.upButton) { this.value++; this.textField.setText(Integer.toString(this.value)); firePropertyChange("value", this.value - 1, this.value); } else if (e.getSource() == this.downButton) { this.value--; this.textField.setText(Integer.toString(this.value)); firePropertyChange("value", this.value + 1, this.value); } }
/** * Creates a new spinner. * * @param value the initial value. */ public Spinner(final int value) { super(new BorderLayout()); this.value = value; this.textField = new JTextField(Integer.toString(this.value)); this.textField.setHorizontalAlignment(SwingConstants.RIGHT); add(this.textField); this.buttonPanel = new JPanel(new GridLayout(2, 1, 0, 1)); this.upButton = new ArrowPanel(ArrowPanel.UP); this.upButton.addMouseListener(this); this.downButton = new ArrowPanel(ArrowPanel.DOWN); this.downButton.addMouseListener(this); this.buttonPanel.add(this.upButton); this.buttonPanel.add(this.downButton); add(this.buttonPanel, BorderLayout.EAST); }
/** * Receives notification of mouse clicks. * * @param e the mouse event. */ public void mouseClicked(final MouseEvent e) { if (e.getSource() == this.upButton) { this.value++; this.textField.setText(Integer.toString(this.value)); firePropertyChange("value", this.value - 1, this.value); } else if (e.getSource() == this.downButton) { this.value--; this.textField.setText(Integer.toString(this.value)); firePropertyChange("value", this.value + 1, this.value); } }