Entweder so:
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
|
addWindowListener(new WindowListener(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
public void windowActivated(WindowEvent e) { }
public void windowDeactivated(WindowEvent e) { toFront(); }
public void windowDeiconified(WindowEvent e) { }
public void windowClosed(WindowEvent e) { }
public void windowIconified(WindowEvent e) { }
public void windowOpened(WindowEvent e) { }
});
|
oder so:
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/**
* 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) {
// Nothing to do
}
}
}
}
|
Achja, Google hab ich mit : "JWindow always on top" gefüttert und nur die letztere Lösung gefunden. Meine (die obere) funktioniert aber auch ohne Polling ganz gut.
gruß, Texx