This patch (committed) makes the MetalSplitPaneDivider paint its background a different color when it has the keyboard focus:

2006-06-06  David Gilbert  <[EMAIL PROTECTED]>

        * javax/swing/plaf/metal/MetalSplitPaneDivider.java
        (paint): If has focus, paint special background color,
        * javax/swing/plaf/basic/BasicSplitPaneUI.java
        (FocusHandler.focusGained): Implemented,
        (FocusHandler.focusLost): Implemented.

I'm working with the test app from a Sun bug report:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4110480

Now I need to track down why the focus changes (TAB key etc.) aren't the same as the reference implementation (perhaps I've done something wrong in the keyboard bindings, or perhaps our focus manager is broken). I provide the link above in case anyone else wants to take a look at this small test program.

Regards,

Dave
Index: javax/swing/plaf/basic/BasicSplitPaneUI.java
===================================================================
RCS file: 
/sources/classpath/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java,v
retrieving revision 1.29
diff -u -r1.29 BasicSplitPaneUI.java
--- javax/swing/plaf/basic/BasicSplitPaneUI.java        6 Jun 2006 15:12:10 
-0000       1.29
+++ javax/swing/plaf/basic/BasicSplitPaneUI.java        6 Jun 2006 20:33:00 
-0000
@@ -680,7 +680,9 @@
      */
     public void focusGained(FocusEvent ev)
     {
-      // FIXME: implement.
+      // repaint the divider because its background color may change due to
+      // the focus state...
+      divider.repaint();
     }
 
     /**
@@ -690,7 +692,9 @@
      */
     public void focusLost(FocusEvent ev)
     {
-      // FIXME: implement.
+      // repaint the divider because its background color may change due to
+      // the focus state...
+      divider.repaint();
     }
   }
 
Index: javax/swing/plaf/metal/MetalSplitPaneDivider.java
===================================================================
RCS file: 
/sources/classpath/classpath/javax/swing/plaf/metal/MetalSplitPaneDivider.java,v
retrieving revision 1.8
diff -u -r1.8 MetalSplitPaneDivider.java
--- javax/swing/plaf/metal/MetalSplitPaneDivider.java   11 May 2006 17:05:55 
-0000      1.8
+++ javax/swing/plaf/metal/MetalSplitPaneDivider.java   6 Jun 2006 20:33:00 
-0000
@@ -1,5 +1,5 @@
 /* MetalSplitPaneDivider.java
-Copyright (C) 2005 Free Software Foundation, Inc.
+Copyright (C) 2005, 2006, Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -47,15 +47,15 @@
 
 import javax.swing.JSplitPane;
 import javax.swing.SwingConstants;
+import javax.swing.UIManager;
 import javax.swing.border.Border;
 import javax.swing.plaf.basic.BasicArrowButton;
 import javax.swing.plaf.basic.BasicSplitPaneDivider;
 
 /**
- * The divider that is used by the MetalSplitPaneUI.
+ * The divider that is used by the [EMAIL PROTECTED] MetalSplitPaneUI}.
  *
  * @author Roman Kennke ([EMAIL PROTECTED])
- *
  */
 class MetalSplitPaneDivider extends BasicSplitPaneDivider
 {
@@ -72,7 +72,7 @@
   int orientation;
   
   /**
-   * Creates a new instance of MetalSplitPaneDivider.
+   * Creates a new instance of <code>MetalSplitPaneDivider</code>.
    *
    * @param ui the <code>MetalSplitPaneUI</code> that uses this divider
    */
@@ -95,6 +95,12 @@
   {
     Dimension s = getSize();
 
+    if (splitPane.hasFocus())
+      {
+        g.setColor(UIManager.getColor("SplitPane.dividerFocusColor"));
+        g.fillRect(0, 0, s.width, s.height);
+      }
+    
     // Paint border if one exists.
     Border border = getBorder();
     if (border != null)

Reply via email to