classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: various JInternalFrame fixes


From: Roman Kennke
Subject: [cp-patches] FYI: various JInternalFrame fixes
Date: Sun, 10 Jul 2005 22:18:59 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050331)

I committed the following fixes for JInternalFrame and related classes.
I noted strange behaviour in the JDK that I imitated: There are several colors defined for InternalFrame.border. Strange is that these colors are not used in the implementation of the borders, but instead some other colors are used. I tried to imitate this, put the values in BasicLookAndFeel that are also in the BasicLookAndFeel of the JDK, and use the other values that are also used in the JDK.


2005-07-10  Roman Kennke  <address@hidden>

        * javax/swing/JInternalFrame.java
        (pack): Set the JInternalFrame's own size here instead of
        layouting its children (this is triggered by setSize anyway).
        * javax/swing/plaf/basic/BasicInternalFrameUI.java
        (installDefaults): Set the correct border for InternalFrames.
        Set InternalFrames to invisible by default.
        * javax/swing/plaf/basic/BasicLookAndFeel.java
        (initComponentDefaults): Set correct color values for
        InternalFrames.

/Roman
Index: javax/swing/JInternalFrame.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JInternalFrame.java,v
retrieving revision 1.19
diff -u -r1.19 JInternalFrame.java
--- javax/swing/JInternalFrame.java     2 Jul 2005 20:32:47 -0000       1.19
+++ javax/swing/JInternalFrame.java     10 Jul 2005 20:10:46 -0000
@@ -1165,7 +1165,7 @@
       {
        // Do nothing if they don't want to be restored first.
       }
-    doLayout();
+    setSize(getPreferredSize());
   }
 
   /**
Index: javax/swing/plaf/basic/BasicInternalFrameUI.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java,v
retrieving revision 1.11
diff -u -r1.11 BasicInternalFrameUI.java
--- javax/swing/plaf/basic/BasicInternalFrameUI.java    2 Jul 2005 20:32:50 
-0000       1.11
+++ javax/swing/plaf/basic/BasicInternalFrameUI.java    10 Jul 2005 20:10:47 
-0000
@@ -56,6 +56,7 @@
 import java.beans.PropertyVetoException;
 import java.beans.VetoableChangeListener;
 
+import javax.swing.BorderFactory;
 import javax.swing.DefaultDesktopManager;
 import javax.swing.DesktopManager;
 import javax.swing.JComponent;
@@ -64,11 +65,16 @@
 import javax.swing.KeyStroke;
 import javax.swing.SwingConstants;
 import javax.swing.SwingUtilities;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
 import javax.swing.border.AbstractBorder;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
 import javax.swing.event.InternalFrameEvent;
 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;
@@ -1172,9 +1178,27 @@
    * This method installs the defaults specified by the look and feel.
    */
   protected void installDefaults()
-  {
-    // FIXME: Move border to MetalBorders
-    frame.setBorder(new InternalFrameBorder());
+    {
+      // 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 lineColor = new Color(238, 238, 238);
+      Border inner = BorderFactory.createLineBorder(lineColor, 1);
+      Color shadowInner = new Color(184, 207, 229);
+      Color shadowOuter = new Color(122, 138, 153);
+      Border outer = BorderFactory.createBevelBorder(BevelBorder.RAISED,
+                                                    Color.WHITE,
+                                                    Color.WHITE,
+                                                    shadowOuter,
+                                                    shadowInner);
+      Border border = new BorderUIResource.CompoundBorderUIResource(outer,
+                                                                   inner);
+      frame.setBorder(border);
+
+      // InternalFrames are invisible by default.
+      frame.setVisible(false);
   }
 
   /**
Index: javax/swing/plaf/basic/BasicLookAndFeel.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java,v
retrieving revision 1.26
diff -u -r1.26 BasicLookAndFeel.java
--- javax/swing/plaf/basic/BasicLookAndFeel.java        8 Jul 2005 15:24:08 
-0000       1.26
+++ javax/swing/plaf/basic/BasicLookAndFeel.java        10 Jul 2005 20:10:48 
-0000
@@ -455,10 +455,10 @@
       "InternalFrame.border",
       new BorderUIResource.CompoundBorderUIResource(null, null),
       "InternalFrame.borderColor", new ColorUIResource(light),
-      "InternalFrame.borderDarkShadow", new ColorUIResource(shadow),
-      "InternalFrame.borderHighlight", new ColorUIResource(highLight),
-      "InternalFrame.borderLight", new ColorUIResource(light),
-      "InternalFrame.borderShadow", new ColorUIResource(shadow),
+      "InternalFrame.borderDarkShadow", new ColorUIResource(Color.BLACK),
+      "InternalFrame.borderHighlight", new ColorUIResource(Color.WHITE),
+      "InternalFrame.borderLight", new ColorUIResource(Color.LIGHT_GRAY),
+      "InternalFrame.borderShadow", new ColorUIResource(Color.GRAY),
       "InternalFrame.closeIcon", BasicIconFactory.createEmptyFrameIcon(),
       // XXX Don't use gif
 //      "InternalFrame.icon", new IconUIResource(new 
ImageIcon("icons/JavaCup.gif")),

reply via email to

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