/** * Creates a ScrollButton. * * @param type one of the four values - NORTH, SOUTH, WEST, EAST as defined in SwingConstants. */ public ScrollButton(int type) { _type = type; switch (type) { case SwingConstants.NORTH: setIcon(JideIconsFactory.getImageIcon(JideIconsFactory.Arrow.UP)); break; case SwingConstants.SOUTH: setIcon(JideIconsFactory.getImageIcon(JideIconsFactory.Arrow.DOWN)); break; case SwingConstants.WEST: setIcon(JideIconsFactory.getImageIcon(JideIconsFactory.Arrow.LEFT)); break; case SwingConstants.EAST: setIcon(JideIconsFactory.getImageIcon(JideIconsFactory.Arrow.RIGHT)); break; } addActionListener(this); addMouseListener(this); setPreferredSize(new Dimension(10, 10)); setMinimumSize(new Dimension(10, 10)); }
/** * Creates the scroll button. You can override this method to change the attributes on the button. For example, you * can do this to create a bigger scroll button. * <code><pre> * SimpleScrollPane pane = new SimpleScrollPane(){ * protected AbstractButton createScrollButton(int type) { * AbstractButton scrollButton = super.createScrollButton(type); * scrollButton.setPreferredSize(new Dimension(20, 20)); * return scrollButton; * } * }; * </pre></code> * * @param type the type of the scroll button. It could be {@link javax.swing.SwingConstants#NORTH}, {@link * javax.swing.SwingConstants#SOUTH}, {@link javax.swing.SwingConstants#WEST} or {@link * javax.swing.SwingConstants#EAST} . * @return the scroll button. */ protected AbstractButton createScrollButton(int type) { return new ScrollButton(type); }
private void updateTimer(MouseEvent e) { if (_timer != null) { _timer.setDelay(getDelay(e)); } }
public void mouseReleased(MouseEvent e) { if (!isScrollOnRollover()) { stopTimer(); } else { updateTimer(e); } }
public void mousePressed(MouseEvent e) { if (!isScrollOnRollover()) { startTimer(e, 500); } else { updateTimer(e); } }
public void mouseEntered(MouseEvent e) { if (isScrollOnRollover()) { startTimer(e, 500); } }
public void mouseExited(MouseEvent e) { if (isScrollOnRollover()) { stopTimer(); } } }