Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent e)
if (e.getActionCommand() == SHOW) {
window.pack();
window.setVisible(true);
} else { //CLEAR
display.setText("");
}
|
void | displayMessage(java.lang.String prefix, java.awt.event.FocusEvent e)
display.append(prefix
+ ": "
+ e.getComponent()
+ newline);
|
public void | focusGained(java.awt.event.FocusEvent e)
displayMessage("Focus gained", e);
|
public void | focusLost(java.awt.event.FocusEvent e)
displayMessage("Focus lost", e);
|
public void | init()
b1 = new JButton("Click to bring up a window.");
b1.setActionCommand(SHOW);
b1.addActionListener(this);
b2 = new JButton("Click to clear the display.");
b2.setActionCommand(CLEAR);
b2.addActionListener(this);
display = new JTextArea();
display.setEditable(false);
JScrollPane scrollPane = new JScrollPane(display);
scrollPane.setPreferredSize(new Dimension(375, 125));
JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout());
contentPane.add(b1, BorderLayout.NORTH);
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(b2, BorderLayout.SOUTH);
setContentPane(contentPane);
//Create but don't show window.
window = new FocusWindow(this);
|
public void | stop()
SwingUtilities.invokeLater(new Runnable() {
public void run() {
window.setVisible(false);
}
});
|