classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: javax.swing.JComponent fixlet


From: Roman Kennke
Subject: [cp-patches] FYI: javax.swing.JComponent fixlet
Date: Wed, 18 May 2005 10:20:04 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

Hi,

I made JComponent requestFocusEnabled by default and added the method requestFocusInWindow()

2005-05-18  Roman Kennke  <address@hidden>

       * javax/swing/JComponent
       (constructor): Make component requestFocusEnabled by default.
       (requestFocusInWindow): Added method.


/Roman

Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- javax/swing/JComponent.java 15 May 2005 09:49:20 -0000      1.38
+++ javax/swing/JComponent.java 18 May 2005 08:18:09 -0000      1.39
@@ -400,6 +400,7 @@
     setDropTarget(new DropTarget());
     defaultLocale = Locale.getDefault();
     debugGraphicsOptions = DebugGraphics.NONE_OPTION;
+    setRequestFocusEnabled(true);
   }
 
   /**
@@ -2324,6 +2325,33 @@
   }
 
   /**
+   * Requests that this component gets the input focus if the top level
+   * window that contains this component has the focus and the
+   * requestFocusEnabled property is set to <code>true</code>.
+   *
+   * The preconditions that have to be met to become a focus owner is that
+   * the component must be displayable, visible and focusable.
+   *
+   * Note that this signals only a request for becoming focused. There are
+   * situations in which it is not possible to get the focus. So developers
+   * should not assume that the component has the focus until it receives
+   * a address@hidden java.awt.event.FocusEvent} with a value of
+   * address@hidden java.awt.event.FocusEvent.FOCUS_GAINED}.
+   *
+   * @return <code>false</code> if the focus change request will definitly
+   *     fail, <code>true</code> if it will likely succeed
+   *
+   * @see address@hidden Component#requestFocusInWindow()}
+   */
+  public boolean requestFocusInWindow()
+  {
+    if (isRequestFocusEnabled())
+      return super.requestFocusInWindow();
+    else
+      return false;
+  }
+
+  /**
    * This method is overridden to make it public so that it can be used
    * by look and feel implementations.
    *

reply via email to

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