J
Jan Burse
Dear All,
Just fidling around with a Android / Swing port.
Just wonder whether somebody has worked on an
untility to provide the following under Swing
which is inspired by the Android View(*):
postDelayed(Runnable r, int d):
Posts an event on the EDT, which will
invoked r after a delay of d millisecond.
removeCallbacks(Runnable r):
Immediately remove all events from the
EDT that would invoke r.
One could use javax.swing.Timer for the first
method. Something along:
public void postDelayed(final Runnable r, int d) {
final Timer t=new Timer(d,new ActionListener() {
public void actionPerformed(ActionEvent e) {
r.run();
}
});
t.setRepeats(false);
t.start();
}
But then for the second method one would need to
track the created timers, so as to be able to
selectively stop them.
Anybody already implemented a corresponding utility
in the spirit of SwingUtil.invokeLater/invokeAndWait?
Would be glad to receive hint so as not to reinvent
the wheel.
Bye
(*)
http://developer.android.com/reference/android/view/View.html
Just fidling around with a Android / Swing port.
Just wonder whether somebody has worked on an
untility to provide the following under Swing
which is inspired by the Android View(*):
postDelayed(Runnable r, int d):
Posts an event on the EDT, which will
invoked r after a delay of d millisecond.
removeCallbacks(Runnable r):
Immediately remove all events from the
EDT that would invoke r.
One could use javax.swing.Timer for the first
method. Something along:
public void postDelayed(final Runnable r, int d) {
final Timer t=new Timer(d,new ActionListener() {
public void actionPerformed(ActionEvent e) {
r.run();
}
});
t.setRepeats(false);
t.start();
}
But then for the second method one would need to
track the created timers, so as to be able to
selectively stop them.
Anybody already implemented a corresponding utility
in the spirit of SwingUtil.invokeLater/invokeAndWait?
Would be glad to receive hint so as not to reinvent
the wheel.
Bye
(*)
http://developer.android.com/reference/android/view/View.html