I have an always-on-top floating toolbar running while im working
in a native program. Occasionally I need it to grab focus.
My demo code almost works, in that a cursor appears and starts
blinking but when typing occurs it is clear the window focus hasnt changed.
Does this have to be done natively?
edit: toFront() didnt help either. the window flashed in the taskbar but didnt grab focus.
public void start(){
JTextArea jta = new JTextArea();
JFrame win = new JFrame();
win.getContentPane().add(jta, BorderLayout.CENTER);
win.setAlwaysOnTop(true);
win.setSize(400, 100);
win.setLocationRelativeTo(null);
win.setVisible(true);
try{
Thread.sleep(10000);
win.requestFocus();
jta.requestFocus();
win.setLocationRelativeTo(null);
} catch(Exception e){
e.printStackTrace();
}
}
Edited by: TuringPest on Jul 31, 2008 6:54 PM