Zum Inhalt springen

Defaultfokus bei swing


Empfohlene Beiträge

Geschrieben

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

Geschrieben

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

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...