Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Component;

import javax.swing.SwingUtilities;

public class Main {
    /**
     * Requesting focus in a Window should always be done last, after repainting etc.
     * This method calls {@link Component#requestFocusInWindow()} via "invokeLater" 
     * which should make it the last UI action to perform and make it more likely
     * that the focus request works.
     * <br>See also {@link #requestFocusSelectAll(JTextField)}.
     */
    public static void requestFocus(final Component c) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                c.requestFocusInWindow();
            }
        });
    }
}