Java Swing Focus postponeFocus(final Component target)

Here you can find the source of postponeFocus(final Component target)

Description

Setta il focus su form modali

License

Open Source License

Parameter

Parameter Description
target componente che ricevera' il focus

Declaration

public static void postponeFocus(final Component target) 

Method Source Code

//package com.java2s;
/*/*w  w  w.j  ava2 s . c  o m*/
 The GUFF - The GNU Ultimate Framework Facility
 Copyright (C) Simeosoft di Carlo Simeone
       
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.
    
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.
    
 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   
 */

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Main {
    /**
     * Setta il focus su form modali
     *
     * @param target componente che ricevera' il focus
     */
    public static void postponeFocus(final Component target) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                target.dispatchEvent(new FocusEvent(target, FocusEvent.FOCUS_GAINED));
            }
        });
    }
}

Related

  1. isFocused(Component component, boolean recoursive)
  2. isParentWindowFocused(Component component)
  3. isParentWindowFocused(Component component)
  4. isParentWindowFocused(Component component)
  5. paintFocusRect(Graphics g, Rectangle r)
  6. removeFocus(JComponent component)
  7. requestComponentFocus(final Window win, final JComponent comp)
  8. requestComponentFocus(final Window win, final JComponent comp)
  9. requestFocus(final JComponent comp)