Search the web
Sign In
New User? Sign Up
TestFirstUserInterfaces
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
[TFUI] Java Swing JFrame reveal method   Message List  
Reply | Forward Message #974 of 1052 |
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);
}
}
}




Tue Jan 23, 2007 7:51 pm

c_snufkin
Offline Offline
Send Email Send Email

Forward
Message #974 of 1052 |
Expand Messages Author Sort by Date

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*...
Yonatan Elhanan
c_snufkin
Offline Send Email
Jan 23, 2007
8:29 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help