/[classpath]/classpath/javax/swing/plaf/metal/MetalBorders.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/metal/MetalBorders.java

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

revision 1.14 by rabbit78, Mon Sep 12 14:49:52 2005 UTC revision 1.15 by trebligd, Thu Sep 15 12:20:00 2005 UTC
# Line 50  import javax.swing.JMenu; Line 50  import javax.swing.JMenu;
50  import javax.swing.JMenuBar;  import javax.swing.JMenuBar;
51  import javax.swing.JMenuItem;  import javax.swing.JMenuItem;
52  import javax.swing.JTextField;  import javax.swing.JTextField;
53    import javax.swing.JToggleButton;
54  import javax.swing.border.AbstractBorder;  import javax.swing.border.AbstractBorder;
55  import javax.swing.border.Border;  import javax.swing.border.Border;
56  import javax.swing.plaf.BorderUIResource;  import javax.swing.plaf.BorderUIResource;
# Line 70  public class MetalBorders Line 71  public class MetalBorders
71    /** The shared instance for getButtonBorder(). */    /** The shared instance for getButtonBorder(). */
72    private static Border buttonBorder;    private static Border buttonBorder;
73    
74      /** The shared instance for getToggleButtonBorder(). */
75      private static Border toggleButtonBorder;
76    
77    /** The shared instance for getDesktopIconBorder(). */    /** The shared instance for getDesktopIconBorder(). */
78    private static Border desktopIconBorder;    private static Border desktopIconBorder;
79    
# Line 924  public class MetalBorders Line 928  public class MetalBorders
928    }    }
929    
930    /**    /**
931       * A border used for {@link JToggleButton} components.
932       *
933       * @since 1.3
934       */
935      public static class ToggleButtonBorder
936        extends ButtonBorder
937      {
938        /**
939         * Creates a new border instance.
940         */
941        public ToggleButtonBorder()
942        {
943        }
944        
945        /**
946         * Paints the toggle button border.
947         *
948         * @param c the component for which we paint the border
949         * @param g the Graphics context to use
950         * @param x the X coordinate of the upper left corner of c
951         * @param y the Y coordinate of the upper left corner of c
952         * @param w the width of c
953         * @param h the height of c
954         */
955        public void paintBorder(Component c, Graphics g, int x, int y, int w,
956                                int h)
957        {
958          ButtonModel bmodel = null;
959          
960          if (c instanceof AbstractButton)
961            bmodel = ((AbstractButton) c).getModel();
962    
963          Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
964          Color shadow = MetalLookAndFeel.getControlShadow();
965          Color light = MetalLookAndFeel.getWhite();
966          Color middle = MetalLookAndFeel.getControl();
967    
968          if (c.isEnabled())
969            {
970              // draw dark border
971              g.setColor(darkShadow);
972              g.drawRect(x, y, w - 2, h - 2);
973    
974              if (!bmodel.isArmed())
975                {
976                  // draw light border
977                  g.setColor(light);
978                  g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
979                  g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
980                  if (bmodel.isSelected())
981                    g.setColor(middle);
982                  g.drawLine(x + 1, y + 1, x + w - 3, y + 1);
983                  g.drawLine(x + 1, y + 1, x + 1, y + h - 3);
984    
985                  // draw crossing pixels of both borders
986                  g.setColor(shadow);
987                  g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
988                  g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
989                }
990              else
991                {
992                  // draw light border
993                  g.setColor(light);
994                  g.drawLine(x + w - 1, y + 1, x + w - 1, y + h - 1);
995                  g.drawLine(x + 1, y + h - 1, x + w - 1, y + h - 1);
996    
997                  // draw shadow border
998                  g.setColor(shadow);
999                  g.drawLine(x + 1, y + 1, x + w - 2, y + 1);
1000                  g.drawLine(x + 1, y + 1, x + 1, y + h - 2);
1001    
1002                  // draw crossing pixels of both borders
1003                  g.setColor(shadow);
1004                  g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
1005                  g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
1006                  
1007                }
1008              // draw corners
1009              g.setColor(middle);
1010              g.drawLine(x, y + h - 1, x, y + h - 1);
1011              g.drawLine(x + w - 1, y, x + w - 1, y);
1012            }
1013          else
1014            {
1015              // draw disabled border
1016              g.setColor(MetalLookAndFeel.getControlDisabled());
1017              g.drawRect(x, y, w - 2, h - 2);          
1018            }
1019        }
1020      }
1021    
1022      /**
1023     * A border for table header cells.     * A border for table header cells.
1024     *     *
1025     * @since 1.3     * @since 1.3
# Line 999  public class MetalBorders Line 1095  public class MetalBorders
1095    }    }
1096        
1097    /**    /**
1098       * Returns a border for use with {@link JToggleButton} components.
1099       *
1100       * @return A border.
1101       *
1102       * @since 1.3
1103       */
1104      public static Border getToggleButtonBorder()
1105      {
1106        if (toggleButtonBorder == null)
1107          {
1108            Border outer = new ToggleButtonBorder();
1109            Border inner = getMarginBorder();
1110            toggleButtonBorder = new BorderUIResource.CompoundBorderUIResource
1111                (outer, inner);
1112          }
1113        return toggleButtonBorder;
1114      }
1115    
1116      /**
1117     * Returns a border instance that is used with a {@link JInternalFrame} when     * Returns a border instance that is used with a {@link JInternalFrame} when
1118     * it is in the iconified state.     * it is in the iconified state.
1119     *     *

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

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