Methods Summary |
---|
private void | closeDown()
stt.setupCancelled();
hide();
dispose();
|
private void | error()
t.interrupt();
if (SwingUtilities.isEventDispatchThread())
closeDown();
else SwingUtilities.invokeLater(new Runnable() {
public void run() {
closeDown();
}
});
|
public void | run()
// Simulate connecting to server
for (int i = 0; i < stateMessages.length; i++) {
setText(stateMessages[i]);
try {
Thread.sleep(5 * 1000);
} catch (InterruptedException ie) {}
if (Thread.currentThread().isInterrupted())
return;
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
stt.setupDone();
hide();
dispose();
}
});
|
private void | setText(java.lang.String s)
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
label.setText(s);
}
});
} catch (InterruptedException ie) {
error();
} catch (InvocationTargetException ite) {
error();
}
|
private void | setupFrame()
label = new JLabel();
label.setPreferredSize(new Dimension(200, 200));
Container c = getContentPane();
JButton stopButton = new JButton("Stop");
stopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
error();
}
});
c.add(label, BorderLayout.NORTH);
c.add(stopButton, BorderLayout.SOUTH);
|