Use this method to determine whether a particular component has the focus : Focus « Swing JFC « Java






Use this method to determine whether a particular component has the focus

  

import javax.swing.JFrame;

public class Main {
  public static void main() {
    JFrame f = new JFrame();

    boolean b = f.isFocusOwner();
  }
}

   
    
  








Related examples in the same category

1.Focus Cycle SampleFocus Cycle Sample
2.Button FocusButton Focus
3.Focus Traversal ExampleFocus Traversal Example
4.Focus ExampleFocus Example
5.Focus Concepts DemoFocus Concepts Demo
6.Track Focus Demo
7.Focus Traversal DemoFocus Traversal Demo
8.Handling Focus Changes
9.Requests focus for a component
10.Requests focus unless the component already has focus