[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: MetalBorders
From: |
David Gilbert |
Subject: |
[cp-patches] FYI: MetalBorders |
Date: |
Wed, 31 Aug 2005 17:57:33 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.6 (X11/20050728) |
I committed this patch which implements the getTextFieldBorder() method in the
MetalBorders class:
2005-08-31 David Gilbert <address@hidden>
* javax/swing/plaf/metal/MetalBorders.java
(textFieldBorder): new field,
(Flush3DBorder): new class,
(TextFieldBorder): new class,
(getTextFieldBorder): implemented.
Regards,
Dave
Index: javax/swing/plaf/metal/MetalBorders.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalBorders.java,v
retrieving revision 1.10
diff -u -r1.10 MetalBorders.java
--- javax/swing/plaf/metal/MetalBorders.java 24 Aug 2005 08:15:26 -0000
1.10
+++ javax/swing/plaf/metal/MetalBorders.java 31 Aug 2005 16:42:46 -0000
@@ -49,12 +49,14 @@
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
+import javax.swing.JTextField;
import javax.swing.border.AbstractBorder;
import javax.swing.border.Border;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicBorders;
+
/**
* This factory class creates borders for the different Swing components
* UI.
@@ -70,6 +72,9 @@
/** The shared instance for getRolloverButtonBorder(). */
private static Border toolbarButtonBorder;
+ /** The shared instance for getTextFieldBorder(). */
+ private static Border textFieldBorder;
+
/**
* A MarginBorder that gets shared by multiple components.
* Created on demand by the private helper function address@hidden
@@ -186,6 +191,116 @@
}
/**
+ * A simple 3D border.
+ */
+ public static class Flush3DBorder extends AbstractBorder
+ implements UIResource
+ {
+ /**
+ * Creates a new border instance.
+ */
+ public Flush3DBorder()
+ {
+ }
+
+ /**
+ * 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(2, 2, 2, 2);
+ else
+ {
+ newInsets.top = 2;
+ newInsets.left = 2;
+ newInsets.bottom = 2;
+ newInsets.right = 2;
+ }
+ return newInsets;
+ }
+
+ /**
+ * Paints the border for the specified component.
+ *
+ * @param c the component (ignored).
+ * @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)
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getControlDarkShadow());
+ g.drawRect(x, y, w - 2, h - 2);
+ g.setColor(MetalLookAndFeel.getControlHighlight());
+ g.drawRect(x + 1, y + 1, w - 2, h - 2);
+ g.setColor(MetalLookAndFeel.getControl());
+ g.drawLine(x + 1, y + h - 2, x + 1, y + h - 2);
+ g.drawLine(x + w - 2, y + 1, x + w - 2, y + 1);
+ g.setColor(savedColor);
+ }
+
+ }
+
+ /**
+ * A border used for the address@hidden JTextField} component.
+ */
+ public static class TextFieldBorder extends Flush3DBorder
+ implements UIResource
+ {
+ /**
+ * Creates a new border instance.
+ */
+ public TextFieldBorder()
+ {
+ }
+
+ /**
+ * Paints the border for the specified component.
+ *
+ * @param c the component (ignored).
+ * @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)
+ {
+ if (c.isEnabled())
+ super.paintBorder(c, g, x, y, w, h);
+ else
+ {
+ Color savedColor = g.getColor();
+ g.setColor(MetalLookAndFeel.getControlShadow());
+ g.drawRect(x, y, w - 1, h - 1);
+ g.setColor(savedColor);
+ }
+ }
+
+ }
+
+ /**
* A border used when painting address@hidden JInternalFrame} instances.
*/
public static class InternalFrameBorder extends AbstractBorder
@@ -669,6 +784,20 @@
(outer, inner);
}
return buttonBorder;
+ }
+
+ /**
+ * Returns a border for use by the address@hidden JTextField} component.
+ *
+ * @return A border.
+ *
+ * @since 1.3
+ */
+ public static Border getTextFieldBorder()
+ {
+ if (textFieldBorder == null)
+ textFieldBorder = new TextFieldBorder();
+ return textFieldBorder;
}
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: MetalBorders,
David Gilbert <=