Java Code Examples for javax.swing.JFrame.requestFocus()

The following are Jave code examples for showing how to use requestFocus() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: The-Mysterious-Mind-Of-Jack   File: Main.java   View Source Code Vote up 6 votes
public static void main(String[] args) {
    // Main method
    Main m = new Main(); // Create the game object
    Main.m = m;
    frame = new JFrame("Game");
    frame.setResizable(false);
    frame.setUndecorated(true);
    frame.add(m.canvas);
 
    frame.pack();
    frame.addWindowListener(m);

    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    frame.requestFocus();
    m.start();
}
 
Example 2
Project: org.alloytools.alloy   File: OurUtil.java   View Source Code Vote up 5 votes
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
	frame.setVisible(true);
	frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
	frame.requestFocus();
	frame.toFront();
}
 
Example 3
Project: Tarski   File: OurUtil.java   View Source Code Vote up 5 votes
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
   frame.setVisible(true);
   frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
   frame.requestFocus();
   frame.toFront();
}
 
Example 4
Project: Tarski   File: OurUtil.java   View Source Code Vote up 5 votes
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
   frame.setVisible(true);
   frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
   frame.requestFocus();
   frame.toFront();
}
 
Example 5
Project: openjdk-jdk10   File: bug8069348.java   View Source Code Vote up 5 votes
private static void createAndShowGUI() {

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JDesktopPane desktopPane = new JDesktopPane();
        desktopPane.setBackground(DESKTOPPANE_COLOR);

        internalFrame = new JInternalFrame("Test") {

            @Override
            public void paint(Graphics g) {
                super.paint(g);
                g.setColor(FRAME_COLOR);
                g.fillRect(0, 0, getWidth(), getHeight());
            }
        };
        internalFrame.setSize(WIN_WIDTH / 3, WIN_HEIGHT / 3);
        internalFrame.setVisible(true);
        desktopPane.add(internalFrame);

        JPanel panel = new JPanel();
        panel.setLayout(new BorderLayout());
        panel.add(desktopPane, BorderLayout.CENTER);
        frame.add(panel);
        frame.setSize(WIN_WIDTH, WIN_HEIGHT);
        frame.setVisible(true);
        frame.requestFocus();
    }