priescen Geschrieben 2. Februar 2006 Teilen Geschrieben 2. Februar 2006 Hi Leute, ich habe eine kleine Anwendung mit einem Textfeld und einer Textarea und möchte dass immer nur das Textfeld den Fokus hat, so dass ich direckt hier was eintippen kann. thx für euere hilfe Zitieren Link zu diesem Kommentar Auf anderen Seiten teilen Mehr Optionen zum Teilen...
Jaraz Geschrieben 2. Februar 2006 Teilen Geschrieben 2. Februar 2006 public boolean requestFocusInWindow() { return requestFocusHelper(false, false); } /** * Requests that this Component get the input focus, if this Component's * top-level ancestor is already the focused Window. This component must be * displayable, visible, and focusable for the request to be granted. Every * effort will be made to honor the request; however, in some cases it may * be impossible to do so. Developers must never assume that this Component * is the focus owner until this Component receives a FOCUS_GAINED event. * <p> * This method returns a boolean value. If <code>false</code> is returned, * the request is <b>guaranteed to fail</b>. If <code>true</code> is * returned, the request will succeed <b>unless</b> it is vetoed, or an * extraordinary event, such as disposal of the Component's peer, occurs * before the request can be granted by the native windowing system. Again, * while a return value of <code>true</code> indicates that the request is * likely to succeed, developers must never assume that this Component is * the focus owner until this Component receives a FOCUS_GAINED event. * <p> * This method cannot be used to set the focus owner to no Component at * all. Use <code>KeyboardFocusManager.clearGlobalFocusOwner()</code> * instead. * <p> * The focus behavior of this method can be implemented uniformly across * platforms, and thus developers are strongly encouraged to use this * method over <code>requestFocus</code> when possible. Code which relies * on <code>requestFocus</code> may exhibit different focus behavior on * different platforms. * * @return <code>false</code> if the focus change request is guaranteed to * fail; <code>true</code> if it is likely to succeed * @see #requestFocus * @see java.awt.event.FocusEvent * @see #addFocusListener * @see #isFocusable * @see #isDisplayable * @see KeyboardFocusManager#clearGlobalFocusOwner * @since 1.4 */ public boolean requestFocusInWindow() { return requestFocusHelper(false, false); } Gruß Jaraz Zitieren Link zu diesem Kommentar Auf anderen Seiten teilen Mehr Optionen zum Teilen...
Empfohlene Beiträge
Dein Kommentar
Du kannst jetzt schreiben und Dich später registrieren. Wenn Du ein Konto hast, melde Dich jetzt an, um unter Deinem Benutzernamen zu schreiben.