Java AWT KeyboardFocusManager clear global focus owner

Description

Java AWT KeyboardFocusManager clear global focus owner

import java.awt.FlowLayout;
import java.awt.KeyboardFocusManager;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Main {
   public static void main(String[] argv) {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JButton component1 = new JButton("1");
      JButton component2 = new JButton("2");
      JButton component3 = new JButton("3");

      frame.setLayout(new FlowLayout());
      frame.add(component1);// ww  w .ja  v a 2 s .co  m
      frame.add(component2);
      frame.add(component3);

      frame.pack();
      frame.setVisible(true);

      KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
   }
}



PreviousNext

Related