/[classpath]/classpath/javax/swing/plaf/basic/BasicBorders.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicBorders.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by brawer, Thu Jun 19 08:34:18 2003 UTC revision 1.5 by brawer, Thu Jun 19 11:51:01 2003 UTC
# Line 440  public class BasicBorders Line 440  public class BasicBorders
440      {      {
441      }      }
442    } // class SplitPaneBorder    } // class SplitPaneBorder
443    
444    
445      /**
446       * A border for toggle buttons in the Basic look and feel.
447       *
448       * <p><img src="BasicBorders.ToggleButtonBorder-1.png" width="270"
449       * height="135" alt="[A screen shot of this border]" />
450       *
451       * <p>The Sun implementation always seems to draw exactly
452       * the same border, irrespective of the state of the button.
453       * This is rather surprising, but GNU Classpath emulates the
454       * observable behavior.
455       *
456       * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
457       *
458       * @author Sascha Brawer (brawer@dandelis.ch)
459       */
460    public static class ToggleButtonBorder    public static class ToggleButtonBorder
461        extends ButtonBorder
462    {    {
463    } // class ToggleButtonBorder      /**
464  } // class BasicBorders       * Determined using the <code>serialver</code> tool
465         * of Apple/Sun JDK 1.3.1 on MacOS X 10.1.5.
466         */
467        static final long serialVersionUID = -3528666548001058394L;
468    
469        
470        /**
471         * Constructs a new border for drawing a JToggleButton in
472         * the Basic look and feel.
473         *
474         * @param shadow the shadow color.
475         * @param darkShadow a darker variant of the shadow color.
476         * @param highlight the highlight color.
477         * @param lightHighlight a brighter variant of the highlight  color.
478         */
479        public ToggleButtonBorder(Color shadow, Color darkShadow,
480                                  Color highlight, Color lightHighlight)
481        {
482          /* The superclass ButtonBorder substitutes null arguments
483           * with fallback colors.
484           */
485          super(shadow, darkShadow, highlight, lightHighlight);
486        }
487    
488    
489        /**
490         * Paints the ToggleButtonBorder around a given component.
491         *
492         * <p>The Sun implementation always seems to draw exactly
493         * the same border, irrespective of the state of the button.
494         * This is rather surprising, but GNU Classpath emulates the
495         * observable behavior.
496         *
497         * @param c the component whose border is to be painted.
498         * @param g the graphics for painting.
499         * @param x the horizontal position for painting the border.
500         * @param y the vertical position for painting the border.
501         * @param width the width of the available area for painting the border.
502         * @param height the height of the available area for painting the border.
503         *
504         * @see javax.swing.plaf.basic.BasicGraphicsUtils#drawBezel
505         */
506        public void paintBorder(Component c, Graphics  g,
507                                int x, int y, int width, int height)
508        {
509          /* The author of this code tried various variants for setting
510           * the state of the enclosed JToggleButton, but it seems that
511           * the drawn border is always identical. Weird, because this
512           * means that the user does not see whether the JToggleButton
513           * is selected or not.
514           */
515          BasicGraphicsUtils.drawBezel(g, x, y, width, height,
516                                       /* pressed */ false,
517                                       /* default */ false,
518                                       shadow, darkShadow,
519                                       highlight, lightHighlight);
520        }
521    
522    
523        /**
524         * Measures the width of this border.
525         *
526         * @param c the component whose border is to be measured.
527         *
528         * @return an Insets object whose <code>left</code>,
529         *         <code>right</code>, <code>top</code> and
530         *         <code>bottom</code> fields indicate the width of the
531         *         border at the respective edge.
532         *
533         * @see #getBorderInsets(java.awt.Component, java.awt.Insets)
534         */
535        public Insets getBorderInsets(Component c)
536        {
537          /* There is no obvious reason for overriding this method, but we
538           * try to have exactly the same API as the Sun reference
539           * implementation.
540           */
541          return getBorderInsets(c, null);
542        }
543    
544        
545        /**
546         * Measures the width of this border, storing the results into a
547         * pre-existing Insets object.
548         *
549         * @param insets an Insets object for holding the result values.
550         *        After invoking this method, the <code>left</code>,
551         *        <code>right</code>, <code>top</code> and
552         *        <code>bottom</code> fields indicate the width of the
553         *        border at the respective edge.
554         *
555         * @return the same object that was passed for <code>insets</code>.
556         *
557         * @see #getBorderInsets()
558         */
559        public Insets getBorderInsets(Component c, Insets insets)
560        {
561          /* The exact amount has been determined using a test program
562           * that was run on the Apple/Sun JDK 1.3.1 on MacOS X, and the
563           * Sun JDK 1.4.1_01 on GNU/Linux for x86. Both gave [2,2,2,2].
564           */
565          if (insets == null)
566            return new Insets(2, 2, 2, 2);
567    
568          insets.left = insets.right = insets.top = insets.bottom = 2;
569          return insets;
570        }
571      }
572    }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26