
Earthquake Dialog #38
Chapter 5, Windows, Dialogs, and Frames
|
197
HACK
then shows the frame on screen. When the window is opened, the settings
will be pulled from the properties file. When the user quits the program, the
settings will be saved back to the properties file:
public static void main(String[] args) throws Exception {
Toolkit tk = Toolkit.getDefaultToolkit( );
tk.addAWTEventListener(WindowSaver.getInstance( ),
AWTEvent.WINDOW_EVENT_MASK);
final JFrame frame = new JFrame("Hack X");
frame.setName("WSTes.main");
frame.getContentPane( ).add(new JButton("a button"));
JMenuBar mb = new JMenuBar( );
JMenu menu = new JMenu("File");
menu.add(new AbstractAction("Quit") {
public void actionPerformed(ActionEvent evt) {
try {
WindowSaver.saveSettings( );
System.exit(0);
} catch (Exception ex) {
System.out.println(ex);
}
}
});
mb.add(menu);
frame.setJMenuBar(mb);
frame.pack( );
frame.show( );
}
H A C K
#38
Earthquake Dialog Hack #38
Make sure your users really know they got their password wrong.
One of the funny ways that Mac OS X uses animation in its UI is when the
user logs in. If she enters an incorrect login and/or password, the whole
login dialog shakes violently for a second, like a road sign thwacked with a
bat, or a cartoon character who has just run full-speed into a solid object
(say, a picture of a tunnel painted over a wall).
We like this effect a lot, so we thought we’d bring it to ...