1,the upstair tell you a best way.
2,you can extends jwindow
override show() like this:
public void show()
{
super.show();
this.requestfocus();
}
and then add a window listener for
the focus lost event:
addfocuslistener (new java.awt.event.focusadapter () {
public void focuslost (java.awt.event.focusevent evt) {
this.tofront();
}
}
);
it seems to work for me...
3.you can also try to use thread, i recommend this way.
/**
* call this from class consructor
*/
public void initialize() {
topthread top = new topthread();
top.start();
}
/**
* keep jwindow on top (inner class)
*/
class topthread extends thread {
public void run() {
while(true) {
tofront();
/**
* let 10 milliseconds for other code to execute
*/
try {
thread.sleep(10);
}
catch(exception e) {
// do what you wanna do
}
}
}
}
you can see:http://forum.java.sun.com/thread.jsp?forum=57&thread=166992
that's some others discuss it.
闽公网安备 35060202000074号