[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: JInternalFrame border/icon addition
From: |
David Gilbert |
Subject: |
[cp-patches] FYI: JInternalFrame border/icon addition |
Date: |
Wed, 24 Aug 2005 09:57:06 +0000 |
User-agent: |
Mozilla Thunderbird 1.0.6 (X11/20050728) |
I committed this patch to add the Metal-style frame around JInternalFrames, and also
the icon at the top left. There's still more to do on the frame title and control
icons.
2005-08-24 David Gilbert <address@hidden>
* javax/swing/plaf/basic/BasicInternalFrameUI.java
(installDefaults): just fetch border from UIDefaults,
* javax/swing/plaf/metal/MetalIconFactory.java
(InternalFrameDefaultMenuIcon): implemented,
(getInternalFrameDefaultMenuIcon): implemented,
* javax/swing/plaf/metal/MetalLookAndFeel.java
(initComponentDefaults): add values for "InternalFrame.border" and
"InternalFrame.icon".
Regards,
Dave Gilbert
Index: javax/swing/plaf/basic/BasicInternalFrameUI.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java,v
retrieving revision 1.15
diff -u -r1.15 BasicInternalFrameUI.java
--- javax/swing/plaf/basic/BasicInternalFrameUI.java 20 Jul 2005 15:25:54
-0000 1.15
+++ javax/swing/plaf/basic/BasicInternalFrameUI.java 24 Aug 2005 08:48:42
-0000
@@ -74,7 +74,6 @@
import javax.swing.event.InternalFrameListener;
import javax.swing.event.MouseInputAdapter;
import javax.swing.event.MouseInputListener;
-import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.InternalFrameUI;
import javax.swing.plaf.UIResource;
@@ -1178,26 +1177,8 @@
*/
protected void installDefaults()
{
- // This is the border of InternalFrames in the BasicLookAndFeel.
- // Note that there exist entries for various border colors in
- // BasicLookAndFeel's defaults, but obviously they differ
- // from the colors that are actually used by the JDK.
UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- Color borderColor = defaults.getColor("InternalFrame.borderColor");
- Border inner = BorderFactory.createLineBorder(borderColor, 1);
- Color borderDarkShadow = defaults.getColor
- ("InternalFrame.borderDarkShadow");
- Color borderHighlight = defaults.getColor
- ("InternalFrame.borderHighlight");
- Color borderShadow = defaults.getColor("InternalFrame.borderShadow");
- Color borderLight = defaults.getColor("InternalFrame.borderLight");
- Border outer = BorderFactory.createBevelBorder(BevelBorder.RAISED,
- borderShadow,
- borderHighlight,
- borderDarkShadow,
- borderShadow);
- Border border = new BorderUIResource.CompoundBorderUIResource(outer,
- inner);
+ Border border = defaults.getBorder("InternalFrame.border");
frame.setBorder(border);
frame.setFrameIcon(defaults.getIcon("InternalFrame.icon"));
// InternalFrames are invisible by default.
Index: javax/swing/plaf/metal/MetalIconFactory.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalIconFactory.java,v
retrieving revision 1.4
diff -u -r1.4 MetalIconFactory.java
--- javax/swing/plaf/metal/MetalIconFactory.java 22 Jul 2005 08:26:47
-0000 1.4
+++ javax/swing/plaf/metal/MetalIconFactory.java 24 Aug 2005 08:48:43
-0000
@@ -44,6 +44,7 @@
import java.io.Serializable;
import javax.swing.Icon;
+import javax.swing.JInternalFrame;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.plaf.UIResource;
@@ -408,6 +409,75 @@
}
/**
+ * The icon displayed at the top-left corner of a address@hidden
JInternalFrame}.
+ */
+ private static class InternalFrameDefaultMenuIcon
+ implements Icon, Serializable
+ {
+
+ /**
+ * Creates a new instance.
+ */
+ public InternalFrameDefaultMenuIcon()
+ {
+ }
+
+ /**
+ * Returns the width of the icon, in pixels.
+ *
+ * @return The width of the icon.
+ */
+ public int getIconWidth()
+ {
+ return 16;
+ }
+
+ /**
+ * Returns the height of the icon, in pixels.
+ *
+ * @return The height of the icon.
+ */
+ public int getIconHeight()
+ {
+ return 16;
+ }
+
+ /**
+ * Paints the icon at the specified location.
+ *
+ * @param c the component.
+ * @param g the graphics device.
+ * @param x the x coordinate.
+ * @param y the y coordinate.
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ g.setColor(new Color(102, 102, 153));
+ g.fillRect(x + 1, y, 14, 2);
+ g.fillRect(x, y + 1, 2, 14);
+ g.fillRect(x + 1, y + 14, 14, 2);
+ g.fillRect(x + 14, y + 1, 2, 14);
+ g.drawLine(x + 2, y + 5, x + 14, y + 5);
+
+ g.setColor(new Color(204, 204, 255));
+ g.fillRect(x + 2, y + 2, 12, 3);
+
+ g.setColor(new Color(102, 102, 153));
+ g.drawLine(x + 3, y + 3, x + 3, y + 3);
+ g.drawLine(x + 6, y + 3, x + 6, y + 3);
+ g.drawLine(x + 9, y + 3, x + 9, y + 3);
+ g.drawLine(x + 12, y + 3, x + 12, y + 3);
+
+ g.setColor(Color.white);
+ g.fillRect(x + 2, y + 6, 12, 8);
+ g.drawLine(x + 2, y + 2, x + 2, y + 2);
+ g.drawLine(x + 5, y + 2, x + 5, y + 2);
+ g.drawLine(x + 8, y + 2, x + 8, y + 2);
+ g.drawLine(x + 11, y + 2, x + 11, y + 2);
+ }
+ }
+
+ /**
* The icon used to display the thumb control on a horizontally oriented
* address@hidden JSlider} component.
*/
@@ -739,6 +809,17 @@
return new HorizontalSliderThumbIcon();
}
+ /**
+ * Creates a new icon for the menu in a address@hidden JInternalFrame}.
This is the
+ * icon displayed at the top left of the frame.
+ *
+ * @return A menu icon.
+ */
+ public static Icon getInternalFrameDefaultMenuIcon()
+ {
+ return new InternalFrameDefaultMenuIcon();
+ }
+
/**
* Returns the icon used to display the thumb for a vertically oriented
* address@hidden JSlider}.
Index: javax/swing/plaf/metal/MetalLookAndFeel.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,v
retrieving revision 1.40
diff -u -r1.40 MetalLookAndFeel.java
--- javax/swing/plaf/metal/MetalLookAndFeel.java 24 Aug 2005 08:01:00
-0000 1.40
+++ javax/swing/plaf/metal/MetalLookAndFeel.java 24 Aug 2005 08:48:44
-0000
@@ -789,6 +789,8 @@
"ProgressBar.background", new ColorUIResource(getControl()),
"ScrollPane.border", new MetalBorders.ScrollPaneBorder(),
"TabbedPane.background", new ColorUIResource(getControl()),
+ "InternalFrame.border", new MetalBorders.InternalFrameBorder(),
+ "InternalFrame.icon", MetalIconFactory.getInternalFrameDefaultMenuIcon(),
"Label.background", new ColorUIResource(getControl()),
"Label.font", getControlTextFont(),
"Label.disabledForeground", new ColorUIResource(getControlDisabled()),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] FYI: JInternalFrame border/icon addition,
David Gilbert <=