/* Create a component that will replace the spinner models value * with the object returned by <code>spinner.getPreviousValue</code>. * By default the <code>previousButton</code> is a JButton * who's <code>ActionListener</code> updates it's <code>JSpinner</code> * ancestors model. If a previousButton isn't needed (in a subclass) * then override this method to return null. * * @return a component that will replace the spinners model with the * next value in the sequence, or null * @see #installUI * @see #createNextButton */ protected Component createPreviousButton() { Component tmpButton = super.createPreviousButton(); if (tmpButton instanceof JButton) { JButton result = new ArrowButton(SwingConstants.SOUTH); ActionListener al[] = ((JButton) tmpButton).getActionListeners(); for (int i = 0; i < al.length; i++) result.addActionListener(al[i]); MouseListener ml[] = ((JButton) tmpButton).getMouseListeners(); for (int i = 0; i < ml.length; i++) result.addMouseListener(ml[i]); return result; } else return tmpButton; }
/** * Create a component that will replace the spinner models value with the object returned by * <code>spinner.getNextValue</code>. By default the <code>nextButton</code> is a JButton who's * <code>ActionListener</code> updates it's <code>JSpinner</code> ancestors model. If a nextButton * isn't needed (in a subclass) then override this method to return null. * * @return a component that will replace the spinners model with the next value in the sequence, * or null * @see #installUI * @see #createPreviousButton */ protected Component createNextButton() { Component tmpButton = super.createNextButton(); if (tmpButton instanceof JButton) { JButton result = new ArrowButton(SwingConstants.NORTH); ((ArrowButton) result).setDrawBottomBorder(false); result.setBorder( BorderFactory.createMatteBorder(1, 1, 0, 1, UIManager.getColor("Button.borderColor"))); ActionListener al[] = ((JButton) tmpButton).getActionListeners(); for (int i = 0; i < al.length; i++) result.addActionListener(al[i]); MouseListener ml[] = ((JButton) tmpButton).getMouseListeners(); for (int i = 0; i < ml.length; i++) result.addMouseListener(ml[i]); return result; } else return tmpButton; }