Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent e)
if (e.getActionCommand() == SHOW) {
showIt = true;
aFrame.setVisible(true);
} else { //CLEAR
display.setText("");
}
|
public void | componentHidden(java.awt.event.ComponentEvent e)
displayMessage("componentHidden event from "
+ e.getComponent().getClass().getName());
|
public void | componentMoved(java.awt.event.ComponentEvent e)
displayMessage("componentMoved event from "
+ e.getComponent().getClass().getName());
|
public void | componentResized(java.awt.event.ComponentEvent e)
displayMessage("componentResized event from "
+ e.getComponent().getClass().getName());
|
public void | componentShown(java.awt.event.ComponentEvent e)
displayMessage("componentShown event from "
+ e.getComponent().getClass().getName());
|
protected void | displayMessage(java.lang.String message)
display.append(message + newline);
|
public void | init()
display = new JTextArea();
display.setEditable(false);
JScrollPane scrollPane = new JScrollPane(display);
scrollPane.setPreferredSize(new Dimension(200, 75));
getContentPane().add(scrollPane, BorderLayout.CENTER);
JButton b1 = new JButton("Start playing...");
b1.setActionCommand(SHOW);
b1.addActionListener(this);
getContentPane().add(b1, BorderLayout.NORTH);
JButton b2 = new JButton("Clear");
b2.setActionCommand(CLEAR);
b2.addActionListener(this);
getContentPane().add(b2, BorderLayout.SOUTH);
aFrame = new JFrame("A Frame");
ComponentPanel p = new ComponentPanel(this);
aFrame.addComponentListener(this);
p.addComponentListener(this);
aFrame.getContentPane().add(p, BorderLayout.CENTER);
aFrame.pack();
aFrame.addWindowListener(new WindowAdapter() {
// This event handler is executed before the
// default close operation (hide) is applied.
public void windowClosing(WindowEvent e) {
showIt = false;
}
});
|
public void | start()
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (showIt) {
aFrame.setVisible(true);
}
}
});
|
public void | stop()
SwingUtilities.invokeLater(new Runnable() {
public void run() {
aFrame.setVisible(false);
}
});
|