This applet enforces the the single thread rule for Swing programming.
This is achieved by inserting invokeLater() in the event dispatching thread to
ensure that the updating of the progress text - via a JLabel - takes place within the main worker thread.
This has the effect of delaying the action until it can be executed within the main worker threat, avoiding
conflict with the dispatching thread.
The 1st click on the visible button activates the 1st thread in AcionListener, which brings up the JPanels displaying the JSpinner - set up to produce dates. A 2nd click on showDate, then activates a 2nd thread, which produces the date from JSpinner.
This Java applet has been created using jdk1.5.0_02. It has the class structure shown in the UML diagram.
Implemented byApplet to Demonstrate Control of Multithreading
class butRead implements java.awt.event.ActionListener {
public void actionPerformed(ActionEvent e) {
String buttonString = e.getActionCommand();
..........
..........
EventQueue.invokeLater (new Runnable () {
public void run () {
displayThread2();
}
});
..........
..........
}
}
John R. Oliver
Tel: +44 1494-488-409
e-Mail: john.r.oliver@btinternet.com
Web page and Java Class files updated
wef 24 November 2006.