swing: building guis in java · advisable to use only swing widgets. however, much of the...
TRANSCRIPT
Introduction Aside: Inner Classes Aside: Threads Examples
Swing: Building GUIs in Java
ENGI 5895: Software Design
Andrew Vardy
Faculty of Engineering & Applied ScienceMemorial University of Newfoundland
February 10, 2011
Introduction Aside: Inner Classes Aside: Threads Examples
Outline
1 Introduction
2 Aside: Inner Classes
3 Aside: Threads
4 Examples
Introduction Aside: Inner Classes Aside: Threads Examples
Introduction
Swing is the o�cially supported GUI toolkit for Java. It wasdeveloped to replace the GUI components of the Abstract WindowToolkit (AWT). It has the following features:
Pluggable �look and feel� [DEMO]
Numerous standard and specialized widgets (text boxes,buttons, tabbed panels,...)
Swing components render themselves in an OS-independentmanner
Relative layout of components
Nice design choices: Easily extensible with heavy use ofpatterns
Introduction Aside: Inner Classes Aside: Threads Examples
Introduction
Swing is the o�cially supported GUI toolkit for Java. It wasdeveloped to replace the GUI components of the Abstract WindowToolkit (AWT). It has the following features:
Pluggable �look and feel� [DEMO]
Numerous standard and specialized widgets (text boxes,buttons, tabbed panels,...)
Swing components render themselves in an OS-independentmanner
Relative layout of components
Nice design choices: Easily extensible with heavy use ofpatterns
Introduction Aside: Inner Classes Aside: Threads Examples
Introduction
Swing is the o�cially supported GUI toolkit for Java. It wasdeveloped to replace the GUI components of the Abstract WindowToolkit (AWT). It has the following features:
Pluggable �look and feel� [DEMO]
Numerous standard and specialized widgets (text boxes,buttons, tabbed panels,...)
Swing components render themselves in an OS-independentmanner
Relative layout of components
Nice design choices: Easily extensible with heavy use ofpatterns
Introduction Aside: Inner Classes Aside: Threads Examples
Introduction
Swing is the o�cially supported GUI toolkit for Java. It wasdeveloped to replace the GUI components of the Abstract WindowToolkit (AWT). It has the following features:
Pluggable �look and feel� [DEMO]
Numerous standard and specialized widgets (text boxes,buttons, tabbed panels,...)
Swing components render themselves in an OS-independentmanner
Relative layout of components
Nice design choices: Easily extensible with heavy use ofpatterns
Introduction Aside: Inner Classes Aside: Threads Examples
Introduction
Swing is the o�cially supported GUI toolkit for Java. It wasdeveloped to replace the GUI components of the Abstract WindowToolkit (AWT). It has the following features:
Pluggable �look and feel� [DEMO]
Numerous standard and specialized widgets (text boxes,buttons, tabbed panels,...)
Swing components render themselves in an OS-independentmanner
Relative layout of components
Nice design choices: Easily extensible with heavy use ofpatterns
Introduction Aside: Inner Classes Aside: Threads Examples
Introduction
Swing is the o�cially supported GUI toolkit for Java. It wasdeveloped to replace the GUI components of the Abstract WindowToolkit (AWT). It has the following features:
Pluggable �look and feel� [DEMO]
Numerous standard and specialized widgets (text boxes,buttons, tabbed panels,...)
Swing components render themselves in an OS-independentmanner
Relative layout of components
Nice design choices: Easily extensible with heavy use ofpatterns
Introduction Aside: Inner Classes Aside: Threads Examples
Packages
In the past the AWT provided the widgets, but it is generallyadvisable to use only Swing widgets. However, much of thefunctionality provided by AWT has been retained by Swing:
java.awt: Contains superclasses for GUI components, as wellas other useful classes such as Color and Point
java.awt.event: Classes for event handling
javax.swing: Contains the actual GUI components
The Swing components all start with �J�. e.g. JButton, JPanel,JFrame... Avoid the �non-J� versions of these.
Introduction Aside: Inner Classes Aside: Threads Examples
Packages
In the past the AWT provided the widgets, but it is generallyadvisable to use only Swing widgets. However, much of thefunctionality provided by AWT has been retained by Swing:
java.awt: Contains superclasses for GUI components, as wellas other useful classes such as Color and Point
java.awt.event: Classes for event handling
javax.swing: Contains the actual GUI components
The Swing components all start with �J�. e.g. JButton, JPanel,JFrame... Avoid the �non-J� versions of these.
Introduction Aside: Inner Classes Aside: Threads Examples
Packages
In the past the AWT provided the widgets, but it is generallyadvisable to use only Swing widgets. However, much of thefunctionality provided by AWT has been retained by Swing:
java.awt: Contains superclasses for GUI components, as wellas other useful classes such as Color and Point
java.awt.event: Classes for event handling
javax.swing: Contains the actual GUI components
The Swing components all start with �J�. e.g. JButton, JPanel,JFrame... Avoid the �non-J� versions of these.
Introduction Aside: Inner Classes Aside: Threads Examples
Packages
In the past the AWT provided the widgets, but it is generallyadvisable to use only Swing widgets. However, much of thefunctionality provided by AWT has been retained by Swing:
java.awt: Contains superclasses for GUI components, as wellas other useful classes such as Color and Point
java.awt.event: Classes for event handling
javax.swing: Contains the actual GUI components
The Swing components all start with �J�. e.g. JButton, JPanel,JFrame... Avoid the �non-J� versions of these.
Introduction Aside: Inner Classes Aside: Threads Examples
Packages
In the past the AWT provided the widgets, but it is generallyadvisable to use only Swing widgets. However, much of thefunctionality provided by AWT has been retained by Swing:
java.awt: Contains superclasses for GUI components, as wellas other useful classes such as Color and Point
java.awt.event: Classes for event handling
javax.swing: Contains the actual GUI components
The Swing components all start with �J�. e.g. JButton, JPanel,JFrame... Avoid the �non-J� versions of these.
Class Diagram
This is a partial class diagram for AWT and Swing:
In orange are the commonly used containers for other components.In blue are some of the commonly used components. What designpattern do you see here?
Introduction Aside: Inner Classes Aside: Threads Examples
Aside: Inner Classes
You can create classes within classes. These are known as InnerClasses. Why would you want anything so strange?
Like �helper methods� you can create helper classes which areembedded within a larger class
Inner classes have priviledged access to private members of theouter class
Similar to the friend feature of C++, only more contained
Having small classes declared close to their point of use helpsreadibility and maintainability
Introduction Aside: Inner Classes Aside: Threads Examples
Aside: Inner Classes
You can create classes within classes. These are known as InnerClasses. Why would you want anything so strange?
Like �helper methods� you can create helper classes which areembedded within a larger class
Inner classes have priviledged access to private members of theouter class
Similar to the friend feature of C++, only more contained
Having small classes declared close to their point of use helpsreadibility and maintainability
Introduction Aside: Inner Classes Aside: Threads Examples
Aside: Inner Classes
You can create classes within classes. These are known as InnerClasses. Why would you want anything so strange?
Like �helper methods� you can create helper classes which areembedded within a larger class
Inner classes have priviledged access to private members of theouter class
Similar to the friend feature of C++, only more contained
Having small classes declared close to their point of use helpsreadibility and maintainability
Introduction Aside: Inner Classes Aside: Threads Examples
Aside: Inner Classes
You can create classes within classes. These are known as InnerClasses. Why would you want anything so strange?
Like �helper methods� you can create helper classes which areembedded within a larger class
Inner classes have priviledged access to private members of theouter class
Similar to the friend feature of C++, only more contained
Having small classes declared close to their point of use helpsreadibility and maintainability
Introduction Aside: Inner Classes Aside: Threads Examples
Aside: Inner Classes
You can create classes within classes. These are known as InnerClasses. Why would you want anything so strange?
Like �helper methods� you can create helper classes which areembedded within a larger class
Inner classes have priviledged access to private members of theouter class
Similar to the friend feature of C++, only more contained
Having small classes declared close to their point of use helpsreadibility and maintainability
Introduction Aside: Inner Classes Aside: Threads Examples
Life of an Inner Class
Each inner class instance is associated with an outer class instance.Consider this example:
class Outer {private int outValue = 6 ;
public int getValue ( ) {return outValue ;
}//
class Inner1 {private int value ;
//Inner1 ( ) {
value = outValue + 1 ;}
//public int getValue ( ) {
return value ;}
}}
Introduction Aside: Inner Classes Aside: Threads Examples
Life of an Inner Class
Each inner class instance is associated with an outer class instance.Consider this example:
class Outer {private int outValue = 6 ;
public int getValue ( ) {return outValue ;
}//
class Inner1 {private int value ;
//
Inner1 ( ) {value = outValue + 1 ;
}//
public int getValue ( ) {return value ;
}}
}
Introduction Aside: Inner Classes Aside: Threads Examples
Life of an Inner Class
Each inner class instance is associated with an outer class instance.Consider this example:
class Outer {private int outValue = 6 ;
public int getValue ( ) {return outValue ;
}//
class Inner1 {private int value ;
//Inner1 ( ) {
value = outValue + 1 ;}
//
public int getValue ( ) {return value ;
}}
}
Introduction Aside: Inner Classes Aside: Threads Examples
Life of an Inner Class
Each inner class instance is associated with an outer class instance.Consider this example:
class Outer {private int outValue = 6 ;
public int getValue ( ) {return outValue ;
}//
class Inner1 {private int value ;
//Inner1 ( ) {
value = outValue + 1 ;}
//public int getValue ( ) {
return value ;}
}}
Introduction Aside: Inner Classes Aside: Threads Examples
To create an instance of an inner class, we must use the followingsyntax:
OuterClass . InnerClass innerObject = outerObject . new InnerClass ( ) ;
Notice how new is treated like a �eld of the outer class. Here wetest our previous example:
public class TestOuter {public static void main ( String [ ] args ) {
Outer outer = new Outer ( ) ;System . out . println ( outer . getValue ( ) ) ;
//Outer . Inner1 inner = outer . new Inner1 ( ) ;System . out . println ( inner . getValue ( ) ) ;
}}
Introduction Aside: Inner Classes Aside: Threads Examples
To create an instance of an inner class, we must use the followingsyntax:
OuterClass . InnerClass innerObject = outerObject . new InnerClass ( ) ;
Notice how new is treated like a �eld of the outer class. Here wetest our previous example:
public class TestOuter {public static void main ( String [ ] args ) {
Outer outer = new Outer ( ) ;System . out . println ( outer . getValue ( ) ) ;
//Outer . Inner1 inner = outer . new Inner1 ( ) ;System . out . println ( inner . getValue ( ) ) ;
}}
Introduction Aside: Inner Classes Aside: Threads Examples
To create an instance of an inner class, we must use the followingsyntax:
OuterClass . InnerClass innerObject = outerObject . new InnerClass ( ) ;
Notice how new is treated like a �eld of the outer class. Here wetest our previous example:
public class TestOuter {public static void main ( String [ ] args ) {
Outer outer = new Outer ( ) ;System . out . println ( outer . getValue ( ) ) ;
//
Outer . Inner1 inner = outer . new Inner1 ( ) ;System . out . println ( inner . getValue ( ) ) ;
}}
Introduction Aside: Inner Classes Aside: Threads Examples
To create an instance of an inner class, we must use the followingsyntax:
OuterClass . InnerClass innerObject = outerObject . new InnerClass ( ) ;
Notice how new is treated like a �eld of the outer class. Here wetest our previous example:
public class TestOuter {public static void main ( String [ ] args ) {
Outer outer = new Outer ( ) ;System . out . println ( outer . getValue ( ) ) ;
//Outer . Inner1 inner = outer . new Inner1 ( ) ;System . out . println ( inner . getValue ( ) ) ;
}}
Introduction Aside: Inner Classes Aside: Threads Examples
Nested Classes
The general category to which inner classes belong is nestedclasses. A static nested class is like an inner class but does nothave access to the members of the enclosing class:
class OuterClass {. . .static class StaticNestedClass {
. . .}class InnerClass {
. . .}
}
Example from The Java Tutorials: http://download.oracle.com/javase/tutorial/java/javaOO/nested.html
Static nested classes are basically top-level classes that arepackaged within another class for convenience.
Introduction Aside: Inner Classes Aside: Threads Examples
Nested Classes
The general category to which inner classes belong is nestedclasses. A static nested class is like an inner class but does nothave access to the members of the enclosing class:
class OuterClass {. . .static class StaticNestedClass {
. . .}class InnerClass {
. . .}
}
Example from The Java Tutorials: http://download.oracle.com/javase/tutorial/java/javaOO/nested.html
Static nested classes are basically top-level classes that arepackaged within another class for convenience.
Introduction Aside: Inner Classes Aside: Threads Examples
Nested Classes
The general category to which inner classes belong is nestedclasses. A static nested class is like an inner class but does nothave access to the members of the enclosing class:
class OuterClass {. . .static class StaticNestedClass {
. . .}class InnerClass {
. . .}
}
Example from The Java Tutorials: http://download.oracle.com/javase/tutorial/java/javaOO/nested.html
Static nested classes are basically top-level classes that arepackaged within another class for convenience.
Local Classes
A local class is a nested class declared within the body of amethod. Note that it still has access to outer class members:
import java . util . ∗ ;
class Celebrity extends Observable { /∗∗/ }//
class MyOuter1 {int i = 0 ;public void doStuff ( ) {
Celebrity britney = new Celebrity ( ) ;//
// Dec l a r e a l o c a l c l a s s as an Oberverclass MyLocalObserver implements Observer {
public void update ( Observable o , Object arg ) {// . . .i++;
}}
//britney . addObserver ( new MyLocalObserver ( ) ) ;
}}
Local Classes
A local class is a nested class declared within the body of amethod. Note that it still has access to outer class members:
import java . util . ∗ ;
class Celebrity extends Observable { /∗∗/ }//
class MyOuter1 {int i = 0 ;public void doStuff ( ) {
Celebrity britney = new Celebrity ( ) ;//
// Dec l a r e a l o c a l c l a s s as an Oberverclass MyLocalObserver implements Observer {
public void update ( Observable o , Object arg ) {// . . .i++;
}}
//britney . addObserver ( new MyLocalObserver ( ) ) ;
}}
Local Classes
A local class is a nested class declared within the body of amethod. Note that it still has access to outer class members:
import java . util . ∗ ;
class Celebrity extends Observable { /∗∗/ }//
class MyOuter1 {int i = 0 ;public void doStuff ( ) {
Celebrity britney = new Celebrity ( ) ;//
// Dec l a r e a l o c a l c l a s s as an Oberverclass MyLocalObserver implements Observer {
public void update ( Observable o , Object arg ) {// . . .i++;
}}
//
britney . addObserver ( new MyLocalObserver ( ) ) ;}
}
Local Classes
A local class is a nested class declared within the body of amethod. Note that it still has access to outer class members:
import java . util . ∗ ;
class Celebrity extends Observable { /∗∗/ }//
class MyOuter1 {int i = 0 ;public void doStuff ( ) {
Celebrity britney = new Celebrity ( ) ;//
// Dec l a r e a l o c a l c l a s s as an Oberverclass MyLocalObserver implements Observer {
public void update ( Observable o , Object arg ) {// . . .i++;
}}
//britney . addObserver ( new MyLocalObserver ( ) ) ;
}}
Anonymous Inner Classes
A local class is a nested class declared within the body of amethod. Note that it still has access to outer class members:
import java . util . ∗ ;
class Celebrity extends Observable { /∗∗/ }//
class MyOuter2 {int i = 0 ;
//public void doStuff ( ) {
Celebrity britney = new Celebrity ( ) ;//
// Crea te an anonymous i n n e r c l a s s and add as an// o b s e r v e r o f b r i t n e y .britney . addObserver ( new Observer ( ) {
public void update ( Observable o , Object arg ) {// . . .i++;
}} ) ;
}}
Anonymous Inner Classes
A local class is a nested class declared within the body of amethod. Note that it still has access to outer class members:
import java . util . ∗ ;
class Celebrity extends Observable { /∗∗/ }//
class MyOuter2 {int i = 0 ;
//
public void doStuff ( ) {Celebrity britney = new Celebrity ( ) ;
//// Crea te an anonymous i n n e r c l a s s and add as an// o b s e r v e r o f b r i t n e y .britney . addObserver ( new Observer ( ) {
public void update ( Observable o , Object arg ) {// . . .i++;
}} ) ;
}}
Anonymous Inner Classes
A local class is a nested class declared within the body of amethod. Note that it still has access to outer class members:
import java . util . ∗ ;
class Celebrity extends Observable { /∗∗/ }//
class MyOuter2 {int i = 0 ;
//public void doStuff ( ) {
Celebrity britney = new Celebrity ( ) ;//
// Crea te an anonymous i n n e r c l a s s and add as an// o b s e r v e r o f b r i t n e y .britney . addObserver ( new Observer ( ) {
public void update ( Observable o , Object arg ) {// . . .i++;
}} ) ;
}}
Anonymous Inner Classes
A local class is a nested class declared within the body of amethod. Note that it still has access to outer class members:
import java . util . ∗ ;
class Celebrity extends Observable { /∗∗/ }//
class MyOuter2 {int i = 0 ;
//public void doStuff ( ) {
Celebrity britney = new Celebrity ( ) ;//
// Crea te an anonymous i n n e r c l a s s and add as an// o b s e r v e r o f b r i t n e y .britney . addObserver ( new Observer ( ) {
public void update ( Observable o , Object arg ) {// . . .i++;
}} ) ;
}}
Introduction Aside: Inner Classes Aside: Threads Examples
Aside: Threads
A process is a self contained program with its own resources. Athread is a lightweight process. Threads share the memory spaceof the process that spawned them.
A process with multiple threads is useful in situations where variousclients (e.g. the user, network connections) must be continuallyaddressed. However, they introduce a number of potentialproblems. Concurrency is a big topic (the subject of a wholecourse�7894). In this course you are advised to follow theguidelines for using threads in Swing. If you are sure your projectneeds multiple threads, read the following tutorial:
http://download.oracle.com/javase/tutorial/essential/
concurrency/index.html
Introduction Aside: Inner Classes Aside: Threads Examples
Aside: Threads
A process is a self contained program with its own resources. Athread is a lightweight process. Threads share the memory spaceof the process that spawned them.
A process with multiple threads is useful in situations where variousclients (e.g. the user, network connections) must be continuallyaddressed. However, they introduce a number of potentialproblems. Concurrency is a big topic (the subject of a wholecourse�7894). In this course you are advised to follow theguidelines for using threads in Swing. If you are sure your projectneeds multiple threads, read the following tutorial:
http://download.oracle.com/javase/tutorial/essential/
concurrency/index.html
Introduction Aside: Inner Classes Aside: Threads Examples
Aside: Threads
A process is a self contained program with its own resources. Athread is a lightweight process. Threads share the memory spaceof the process that spawned them.
A process with multiple threads is useful in situations where variousclients (e.g. the user, network connections) must be continuallyaddressed. However, they introduce a number of potentialproblems. Concurrency is a big topic (the subject of a wholecourse�7894). In this course you are advised to follow theguidelines for using threads in Swing. If you are sure your projectneeds multiple threads, read the following tutorial:
http://download.oracle.com/javase/tutorial/essential/
concurrency/index.html
Introduction Aside: Inner Classes Aside: Threads Examples
Guideline for Threads in Swing
Swing is not thread-safe. Willy-nilly usage of threads will createproblems! Possible problems range from unresponsive userinterfaces to bizarre crashes and exceptions.
There are three types of threads to be concerned with:
Initial thread(s): Executes the initial code of your application
The event dispatch thread: Handles all events. Almost all ofyour Swing code will run in this thread. Computationallyexpensive tasks should not be executed here.
Worker or background threads: Handle expensive tasksrunning in the background.
Introduction Aside: Inner Classes Aside: Threads Examples
Guideline for Threads in Swing
Swing is not thread-safe. Willy-nilly usage of threads will createproblems! Possible problems range from unresponsive userinterfaces to bizarre crashes and exceptions.
There are three types of threads to be concerned with:
Initial thread(s): Executes the initial code of your application
The event dispatch thread: Handles all events. Almost all ofyour Swing code will run in this thread. Computationallyexpensive tasks should not be executed here.
Worker or background threads: Handle expensive tasksrunning in the background.
Introduction Aside: Inner Classes Aside: Threads Examples
Guideline for Threads in Swing
Swing is not thread-safe. Willy-nilly usage of threads will createproblems! Possible problems range from unresponsive userinterfaces to bizarre crashes and exceptions.
There are three types of threads to be concerned with:
Initial thread(s): Executes the initial code of your application
The event dispatch thread: Handles all events. Almost all ofyour Swing code will run in this thread. Computationallyexpensive tasks should not be executed here.
Worker or background threads: Handle expensive tasksrunning in the background.
Introduction Aside: Inner Classes Aside: Threads Examples
Guideline for Threads in Swing
Swing is not thread-safe. Willy-nilly usage of threads will createproblems! Possible problems range from unresponsive userinterfaces to bizarre crashes and exceptions.
There are three types of threads to be concerned with:
Initial thread(s): Executes the initial code of your application
The event dispatch thread: Handles all events. Almost all ofyour Swing code will run in this thread. Computationallyexpensive tasks should not be executed here.
Worker or background threads: Handle expensive tasksrunning in the background.
Introduction Aside: Inner Classes Aside: Threads Examples
Guideline for Threads in Swing
Swing is not thread-safe. Willy-nilly usage of threads will createproblems! Possible problems range from unresponsive userinterfaces to bizarre crashes and exceptions.
There are three types of threads to be concerned with:
Initial thread(s): Executes the initial code of your application
The event dispatch thread: Handles all events. Almost all ofyour Swing code will run in this thread. Computationallyexpensive tasks should not be executed here.
Worker or background threads: Handle expensive tasksrunning in the background.
Introduction Aside: Inner Classes Aside: Threads Examples
The most important rule is that Swing code should almost alwaysshould be executed in the event-dispatch thread. The code in maincan be considered the initial thread. In Swing applications the mainjob of the initial thread is to create a Runnable object and scheduleit for execution on the event dispatch thread.
Runnable is an interface that consists of nothing but public void
run(). The Runnable created should be passed toSwingUtilities.invokeLater or SwingUtilities.invokeAndWait. In thefollowing, we create an anonymous inner Runnable and callinvokeLater on it:
SwingUtilities . invokeLater ( new Runnable ( ) {public void run ( ) {
createAndShowGUI ( ) ;}
} ) ;
For more details see the Java tutorial on �Concurrency in Swing�:http://download.oracle.com/javase/tutorial/uiswing/
concurrency/index.html
Introduction Aside: Inner Classes Aside: Threads Examples
The most important rule is that Swing code should almost alwaysshould be executed in the event-dispatch thread. The code in maincan be considered the initial thread. In Swing applications the mainjob of the initial thread is to create a Runnable object and scheduleit for execution on the event dispatch thread.
Runnable is an interface that consists of nothing but public void
run(). The Runnable created should be passed toSwingUtilities.invokeLater or SwingUtilities.invokeAndWait. In thefollowing, we create an anonymous inner Runnable and callinvokeLater on it:
SwingUtilities . invokeLater ( new Runnable ( ) {public void run ( ) {
createAndShowGUI ( ) ;}
} ) ;
For more details see the Java tutorial on �Concurrency in Swing�:http://download.oracle.com/javase/tutorial/uiswing/
concurrency/index.html
Introduction Aside: Inner Classes Aside: Threads Examples
The most important rule is that Swing code should almost alwaysshould be executed in the event-dispatch thread. The code in maincan be considered the initial thread. In Swing applications the mainjob of the initial thread is to create a Runnable object and scheduleit for execution on the event dispatch thread.
Runnable is an interface that consists of nothing but public void
run(). The Runnable created should be passed toSwingUtilities.invokeLater or SwingUtilities.invokeAndWait. In thefollowing, we create an anonymous inner Runnable and callinvokeLater on it:
SwingUtilities . invokeLater ( new Runnable ( ) {public void run ( ) {
createAndShowGUI ( ) ;}
} ) ;
For more details see the Java tutorial on �Concurrency in Swing�:http://download.oracle.com/javase/tutorial/uiswing/
concurrency/index.html
Introduction Aside: Inner Classes Aside: Threads Examples
The most important rule is that Swing code should almost alwaysshould be executed in the event-dispatch thread. The code in maincan be considered the initial thread. In Swing applications the mainjob of the initial thread is to create a Runnable object and scheduleit for execution on the event dispatch thread.
Runnable is an interface that consists of nothing but public void
run(). The Runnable created should be passed toSwingUtilities.invokeLater or SwingUtilities.invokeAndWait. In thefollowing, we create an anonymous inner Runnable and callinvokeLater on it:
SwingUtilities . invokeLater ( new Runnable ( ) {public void run ( ) {
createAndShowGUI ( ) ;}
} ) ;
For more details see the Java tutorial on �Concurrency in Swing�:http://download.oracle.com/javase/tutorial/uiswing/
concurrency/index.html
Introduction Aside: Inner Classes Aside: Threads Examples
Examples
Code for the following examples will be posted on the coursewebsite.
FirstSwingFrame
SecondSwingFrame
LayoutPlay
Paint1
Paint2
GameOfLife