Hi everyone,
Reading the TFUI list I've found only this reveal method in Java:
http://tech.groups.yahoo.com/group/TestFirstUserInterfaces/message/564
*The* book isn't available so there might be one there, but I can't check.
Here's one based on phlip's message (564), but without the sleeping
loop. It seems to work, blocking the unit test until closing the
window. It took most of the programming time to realize I'm wait()ing
and notify()ing different objects: 'this' keyword inside and outside
the anonymous WindowListener.
import java.awt.event.WindowEvent;
public class Reveal {
public static void frame(final javax.swing.JFrame aFrame) {
final Object flag = new Object();
// setup on-close
aFrame.setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
aFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
aFrame.removeWindowListener(this);
aFrame.setVisible(false);
synchronized(flag) {
flag.notifyAll();
}
}
});
try {
// show
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
aFrame.pack();
aFrame.setVisible(true);
}
});
// wait until programmer dismisses window
synchronized(flag) {
flag.wait();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}