classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: MetalBorders.InternalFrameBorder


From: David Gilbert
Subject: [cp-patches] FYI: MetalBorders.InternalFrameBorder
Date: Wed, 24 Aug 2005 09:16:50 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050728)

I added an implementation of MetalBorders.InternalFrameBorder:

2005-08-24  David Gilbert  <address@hidden>

        * javax/swing/plaf/metal/MetalBorders.java
        (InternalFrameBorder): implemented.

Regards,

Dave Gilbert
Index: javax/swing/plaf/metal/MetalBorders.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.9
diff -u -r1.9 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java    26 Jul 2005 13:19:04 -0000      
1.9
+++ javax/swing/plaf/metal/MetalBorders.java    24 Aug 2005 08:12:29 -0000
@@ -45,7 +45,7 @@
 
 import javax.swing.AbstractButton;
 import javax.swing.ButtonModel;
-import javax.swing.JButton;
+import javax.swing.JInternalFrame;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
@@ -53,7 +53,6 @@
 import javax.swing.border.Border;
 import javax.swing.plaf.BorderUIResource;
 import javax.swing.plaf.UIResource;
-import javax.swing.plaf.basic.BasicGraphicsUtils;
 import javax.swing.plaf.basic.BasicBorders;
 
 /**
@@ -184,6 +183,101 @@
       newInsets.top = borderInsets.top;
       return newInsets;
     }
+  }
+
+  /**
+   * A border used when painting address@hidden JInternalFrame} instances.
+   */
+  public static class InternalFrameBorder extends AbstractBorder
+    implements UIResource
+  {
+    /**
+     * Creates a new border instance.
+     */
+    public InternalFrameBorder()
+    {
+    }
+    
+    /**
+     * Returns the border insets.
+     * 
+     * @param c  the component (ignored).
+     * 
+     * @return The border insets.
+     */
+    public Insets getBorderInsets(Component c)
+    {
+      return getBorderInsets(c, null);
+    }
+    
+    /**
+     * Returns the border insets.
+     * 
+     * @param c  the component (ignored).
+     * @return The border insets.
+     */
+    public Insets getBorderInsets(Component c, Insets newInsets)
+    {
+      if (newInsets == null)
+        newInsets = new Insets(5, 5, 5, 5);
+      else
+        {
+          newInsets.top = 5;
+          newInsets.left = 5;
+          newInsets.bottom = 5;
+          newInsets.right = 5;
+        }
+      return newInsets;  
+    }
+    
+    /**
+     * Paints the border for the specified component.
+     * 
+     * @param c  the component.
+     * @param g  the graphics device.
+     * @param x  the x-coordinate.
+     * @param y  the y-coordinate.
+     * @param w  the width.
+     * @param h  the height.
+     */
+    public void paintBorder(Component c, Graphics g, int x, int y, int w, 
+        int h)
+    {
+        
+      JInternalFrame f = (JInternalFrame) c;
+      if (f.isSelected())
+        g.setColor(MetalLookAndFeel.getPrimaryControlDarkShadow());
+      else
+        g.setColor(MetalLookAndFeel.getControlDarkShadow());
+      
+      // fill the border background
+      g.fillRect(x, y, w, 5);
+      g.fillRect(x, y, 5, h);
+      g.fillRect(x + w - 5, y, 5, h);
+      g.fillRect(x, y + h - 5, w, 5);
+      
+      // draw a dot in each corner
+      g.setColor(MetalLookAndFeel.getControl());
+      g.fillRect(x, y, 1, 1);
+      g.fillRect(x + w - 1, y, 1, 1);
+      g.fillRect(x + w - 1, y + h - 1, 1, 1);
+      g.fillRect(x, y + h - 1, 1, 1);
+      
+      // draw the lines
+      g.setColor(MetalLookAndFeel.getBlack());
+      g.drawLine(x + 14, y + 2, x + w - 15, y + 2);
+      g.drawLine(x + 14, y + h - 3, x + w - 15, y + h - 3);
+      g.drawLine(x + 2, y + 14, x + 2, y + h - 15);
+      g.drawLine(x + w - 3, y + 14, x + w - 3, y + h - 15);
+      
+      // draw the line highlights
+      g.setColor(MetalLookAndFeel.getControl());
+      g.drawLine(x + 15, y + 3, x + w - 14, y + 3);
+      g.drawLine(x + 15, y + h - 2, x + w - 14, y + h - 2);
+      g.drawLine(x + 3, y + 15, x + 3, y + h - 14);
+      g.drawLine(x + w - 2, y + 15, x + w - 2, y + h - 14);
+    }
+    
   }
 
   /**

reply via email to

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