/** * Returns a shape for the arrow. * * @param t the arrow type. * * @return the arrow shape. */ private Shape getArrow(final int t) { switch (t) { case UP : return getUpArrow(); case DOWN : return getDownArrow(); default : return getUpArrow(); } }
/** * Creates a new arrow panel. * * @param type the arrow type. */ public ArrowPanel(final int type) { this.type = type; setPreferredSize(new Dimension(14, 9)); }
/** * Paints the arrow panel. * * @param g the graphics device for drawing on. */ public void paintComponent(final Graphics g) { super.paintComponent(g); final Graphics2D g2 = (Graphics2D) g; // first determine the size of the drawing area... final Dimension size = getSize(); final Insets insets = getInsets(); this.available.setRect(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); g2.translate(insets.left, insets.top); g2.fill(getArrow(this.type)); }
/** * 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); }
/** * Paints the arrow panel. * * @param g the graphics device for drawing on. */ public void paintComponent(final Graphics g) { super.paintComponent(g); final Graphics2D g2 = (Graphics2D) g; // first determine the size of the drawing area... final Dimension size = getSize(); final Insets insets = getInsets(); this.available.setRect(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); g2.translate(insets.left, insets.top); g2.fill(getArrow(this.type)); }
/** * 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); }
/** * Paints the arrow panel. * * @param g the graphics device for drawing on. */ public void paintComponent(final Graphics g) { super.paintComponent(g); final Graphics2D g2 = (Graphics2D) g; // first determine the size of the drawing area... final Dimension size = getSize(); final Insets insets = getInsets(); this.available.setRect(insets.left, insets.top, size.getWidth() - insets.left - insets.right, size.getHeight() - insets.top - insets.bottom); g2.translate(insets.left, insets.top); g2.fill(getArrow(this.type)); }
/** * Returns a shape for the arrow. * * @param t the arrow type. * * @return the arrow shape. */ private Shape getArrow(final int t) { switch (t) { case UP : return getUpArrow(); case DOWN : return getDownArrow(); default : return getUpArrow(); } }
/** * 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 arrow panel. * * @param type the arrow type. */ public ArrowPanel(final int type) { this.type = type; setPreferredSize(new Dimension(14, 9)); }
/** * Returns a shape for the arrow. * * @param t the arrow type. * * @return the arrow shape. */ private Shape getArrow(final int t) { switch (t) { case UP : return getUpArrow(); case DOWN : return getDownArrow(); default : return getUpArrow(); } }
/** * Creates a new arrow panel. * * @param type the arrow type. */ public ArrowPanel(final int type) { this.type = type; setPreferredSize(new Dimension(14, 9)); }