Here you can find the source of addDefaultFocus(Window window, final JComponent component)
public static void addDefaultFocus(Window window, final JComponent component)
//package com.java2s; import java.awt.Window; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JComponent; public class Main { public static void addDefaultFocus(Window window, final JComponent component) { window.addWindowFocusListener(new WindowAdapter() { /*//from w w w . jav a 2 s. c o m * (non-Javadoc) * * @see * java.awt.event.WindowAdapter#windowGainedFocus(java.awt.event * .WindowEvent) */ @Override public void windowGainedFocus(WindowEvent e) { component.requestFocusInWindow(); } }); } }