classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Added ScrollPaneBorder to javax.swing.plaf.metal.Metal


From: Roman Kennke
Subject: [cp-patches] FYI: Added ScrollPaneBorder to javax.swing.plaf.metal.MetalBorders
Date: Mon, 25 Apr 2005 13:25:08 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

Hi,

the attached patch adds the inner class ScrollPaneBorder to javax.swing.plaf.metal.MetalBorders.

2005-04-25  Roman Kennke  <address@hidden>

       * javax/swing/plaf/metal/MetalBorders.java:
       Added inner class ScrollPaneBorder.
       * javax/swing/plaf/metal/MetalLookAndFeel.java
       (initComponentDefaults): Added default for "ScrollPane.border"
       to use the new ScrollPaneBorder.

/Roman

Index: javax/swing/plaf/metal/MetalBorders.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.4
diff -u -r1.4 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java    19 Apr 2005 07:59:02 -0000      
1.4
+++ javax/swing/plaf/metal/MetalBorders.java    25 Apr 2005 11:13:21 -0000
@@ -184,6 +184,82 @@
   }
 
   /**
+   * A border for JScrollPanes.
+   */
+  public static class ScrollPaneBorder
+    extends AbstractBorder
+    implements UIResource
+  {
+    /** The border insets. */
+    private static Insets insets = new Insets(1, 1, 2, 2);
+    
+    /**
+     * Constructs a new ScrollPaneBorder.
+     */
+    public ScrollPaneBorder()
+    {
+    }
+    
+    /**
+     * Returns the insets of the border for the Component <code>c</code>.
+     *
+     * @param c the Component for which we return the border insets
+     */
+    public Insets getBorderInsets(Component c)
+    {
+      return insets;
+    }
+
+    /**
+     * Paints the border.
+     *
+     * @param c the Component for which the border is painted
+     * @param g the Graphics context
+     * @param x the X coordinate of the upper left corner of the border
+     * @param y the Y coordinate of the upper left corner of the border
+     * @param w the width of the border
+     * @param h the height of the border
+     */
+    public void paintBorder(Component c, Graphics g, int x, int y,
+                            int w, int h)
+    {
+      Color darkShadow = MetalLookAndFeel.getControlDarkShadow();
+      Color shadow = MetalLookAndFeel.getControlShadow();
+      Color light = MetalLookAndFeel.getWhite();
+      Color middle = MetalLookAndFeel.getControl();
+
+      // paint top border line
+      g.setColor(darkShadow);
+      g.drawLine(x, y, x + w - 2, y);
+
+      // paint left border line
+      g.drawLine(x, y, x, y + h - 2);
+ 
+      // paint right inner border line
+      g.drawLine(x + w - 2, y, x + w - 2, y + h + 1);
+
+      // paint bottom inner border line
+      g.drawLine(x + 2, y + h - 2, x + w - 2, y + h - 2);
+
+      // draw right outer border line
+      g.setColor(light);
+      g.drawLine(x + w - 1, y, x + w - 1, y + h - 1);
+
+      // draw bottom outer border line
+      g.drawLine(x, y + h - 1, x + w - 1, y + h - 1);
+
+      // paint the lighter points
+      g.setColor(middle);
+      g.drawLine(x + w - 1, y, x + w - 1, y);
+      g.drawLine(x + w - 2, y + 2, x + w - 2, y + 2);
+      g.drawLine(x, y + h - 1, x, y + h - 1);
+      g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
+
+    }
+    
+  }
+  
+  /**
    * This border is used in Toolbar buttons as inner border.
    */
   static class RolloverMarginBorder extends AbstractBorder
Index: javax/swing/plaf/metal/MetalLookAndFeel.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,v
retrieving revision 1.17
diff -u -r1.17 MetalLookAndFeel.java
--- javax/swing/plaf/metal/MetalLookAndFeel.java        20 Apr 2005 13:43:06 
-0000      1.17
+++ javax/swing/plaf/metal/MetalLookAndFeel.java        25 Apr 2005 11:13:21 
-0000
@@ -474,6 +474,7 @@
       "Slider.background", new ColorUIResource(getControl()),
       "OptionPane.background", new ColorUIResource(getControl()),
       "ProgressBar.background", new ColorUIResource(getControl()),
+      "ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
       "TabbedPane.background", new ColorUIResource(getControl()),
       "Label.background", new ColorUIResource(getControl()),
       "Label.font", getControlTextFont(),
Index: javax/swing/tree/DefaultTreeSelectionModel.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/tree/DefaultTreeSelectionModel.java,v
retrieving revision 1.10
diff -u -r1.10 DefaultTreeSelectionModel.java
--- javax/swing/tree/DefaultTreeSelectionModel.java     25 Apr 2005 08:42:17 
-0000      1.10
+++ javax/swing/tree/DefaultTreeSelectionModel.java     25 Apr 2005 11:13:21 
-0000
@@ -231,9 +231,9 @@
    *
    * @param path the path to set as selection
    */
-  public void setSelectionPath(TreePath value0)
+  public void setSelectionPath(TreePath path)
   {
-    // TODO
+    selection = new TreePath[] { path };
   }
 
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]