src/macosx/classes/com/apple/laf/AquaSpinnerUI.java

Print this page




 144     protected PropertyChangeListener createPropertyChangeListener() {
 145         return new PropertyChangeHandler();
 146     }
 147 
 148     protected TransparentButton createPreviousButton() {
 149         final TransparentButton b = new TransparentButton();
 150         b.addActionListener(getPreviousButtonHandler());
 151         b.addMouseListener(getPreviousButtonHandler());
 152         b.setInheritsPopupMenu(true);
 153         return b;
 154     }
 155 
 156     protected TransparentButton createNextButton() {
 157         final TransparentButton b = new TransparentButton();
 158         b.addActionListener(getNextButtonHandler());
 159         b.addMouseListener(getNextButtonHandler());
 160         b.setInheritsPopupMenu(true);
 161         return b;
 162     }
 163 



























 164     class TransparentButton extends JButton implements SwingConstants {
 165         boolean interceptRepaints = false;
 166 
 167         public TransparentButton() {
 168             super();
 169             setFocusable(false);
 170             // only intercept repaints if we are after this has been initialized
 171             // otherwise we can't talk to our containing class
 172             interceptRepaints = true;
 173         }
 174 
 175         public void paint(final Graphics g) {}
 176 
 177         public void repaint() {
 178             // only intercept repaints if we are after this has been initialized
 179             // otherwise we can't talk to our containing class
 180             if (interceptRepaints) {
 181                 if (spinPainter == null) return;
 182                 spinPainter.repaint();
 183             }




 144     protected PropertyChangeListener createPropertyChangeListener() {
 145         return new PropertyChangeHandler();
 146     }
 147 
 148     protected TransparentButton createPreviousButton() {
 149         final TransparentButton b = new TransparentButton();
 150         b.addActionListener(getPreviousButtonHandler());
 151         b.addMouseListener(getPreviousButtonHandler());
 152         b.setInheritsPopupMenu(true);
 153         return b;
 154     }
 155 
 156     protected TransparentButton createNextButton() {
 157         final TransparentButton b = new TransparentButton();
 158         b.addActionListener(getNextButtonHandler());
 159         b.addMouseListener(getNextButtonHandler());
 160         b.setInheritsPopupMenu(true);
 161         return b;
 162     }
 163 
 164     /**
 165      * {@inheritDoc}
 166      */
 167     public int getBaseline(JComponent c, int width, int height) {
 168         super.getBaseline(c, width, height);
 169         JComponent editor = spinner.getEditor();
 170         Insets insets = spinner.getInsets();
 171         width = width - insets.left - insets.right;
 172         height = height - insets.top - insets.bottom;
 173         if (width >= 0 && height >= 0) {
 174             int baseline = editor.getBaseline(width, height);
 175             if (baseline >= 0) {
 176                 return insets.top + baseline;
 177             }
 178         }
 179         return -1;
 180     }
 181 
 182     /**
 183      * {@inheritDoc}
 184      */
 185     public Component.BaselineResizeBehavior getBaselineResizeBehavior(
 186             JComponent c) {
 187         super.getBaselineResizeBehavior(c);
 188         return spinner.getEditor().getBaselineResizeBehavior();
 189     }
 190 
 191     class TransparentButton extends JButton implements SwingConstants {
 192         boolean interceptRepaints = false;
 193 
 194         public TransparentButton() {
 195             super();
 196             setFocusable(false);
 197             // only intercept repaints if we are after this has been initialized
 198             // otherwise we can't talk to our containing class
 199             interceptRepaints = true;
 200         }
 201 
 202         public void paint(final Graphics g) {}
 203 
 204         public void repaint() {
 205             // only intercept repaints if we are after this has been initialized
 206             // otherwise we can't talk to our containing class
 207             if (interceptRepaints) {
 208                 if (spinPainter == null) return;
 209                 spinPainter.repaint();
 210             }