A browser with JavaScript enabled is required for this page to operate properly.
Trail: Creating a GUI with JFC/Swing
Lesson: Using Swing Components
Home Page > Creating a GUI with JFC/Swing > Using Swing Components

Using Swing Components: Examples

The table that follows lists every example in the Using Swing Components lesson, with links to required files and to where each example is discussed. The first column of the table has links to JNLP files that let you run the examples using Java™ Web Start.


NOTE: Release 6.0 is required to run all applets and Java Web Start examples. Most examples will run on an earlier release but you must compile and run them locally.

To run an example using Java Web Start, click the [Launch] link in the first column of the table. The first time you run an example, there will be a delay while Java Web Start downloads the JAR file containing the class files for this lesson's examples. Afterward, the examples should execute more quickly.

Compiling and Running the Examples Locally

The second column in the table below has links to zip files for each demo that you can open and run in the NetBeans IDE. Refer to Running Tutorial Examples in NetBeans IDE for more information.

If you download an individual example, take care to have all the necessary files in the proper hierarchy when you compile and run it. All of the examples in the Swing tutorial are placed in a package. For example, the components examples are placed in a components package. See the following image for the complete structure. Note that any examples using images expect their image files to be in a directory named images that is in the same directory as the example's src files. Here is a typical setup:

ButtonDemo's Directory structure

You can find out which files each example needs by consulting the following table or by looking at the comments at the beginning of each source file.

Table of Examples

Example Zip File
(contains all files necessary for the example plus NetBeans IDE project metadata)
Source Files
(first file has the main method, except for examples that run only as applets)
Image and Other Files Where Described
BorderDemo [Launch]Border Demo Project BorderDemo.java wavy.gif How to Use Borders
ButtonDemo [Launch] Button Demo Project ButtonDemo.java right.gif, middle.gif, left.gif How to Use Buttons, ...
ButtonHtmlDemo [Launch] Button Html Demo Project ButtonHtmlDemo.java right.gif, middle.gif, left.gif How to Use Buttons, ...
CheckBoxDemo [Launch] Check Box Demo Project CheckBoxDemo.java All of the images in the images/geek directory. How to Use Buttons, ...
ColorChooserDemo [Launch] Color Chooser Demo Project ColorChooserDemo.java   How to Use Color Choosers
ColorChooserDemo2 [Launch] Color Chooser 2 Demo Project ColorChooserDemo2.java
   CrayonPanel.java
red.gif, yellow.gif, green.gif, blue.gif How to Use Color Choosers
ComboBoxDemo [Launch] Combo Box Demo Project ComboBoxDemo.java Bird.gif, Cat.gif, Dog.gif, Rabbit.gif, Pig.gif How to Use Combo Boxes
ComboBoxDemo2 [Launch] Combo Box 2 Demo Project ComboBoxDemo2.java   How to Use Combo Boxes
Converter [Launch] Converter Project Converter.java
   ConversionPanel.java
   ConverterRangeModel.java
   FollowerRangeModel.java
   Unit.java
  How to Use Panels;
Using Models
CustomComboBoxDemo [Launch] Custom Combo Box Demo Project CustomComboBoxDemo.java Bird.gif, Cat.gif, Dog.gif, Rabbit.gif, Pig.gif How to Use Combo Boxes
CustomIconDemo [Launch] Custom Icon Demo Project CustomIconDemo.java
   ArrowIcon.java
middle.gif How to Use Icons
DialogDemo [Launch] Dialog Demo Project DialogDemo.java
   CustomDialog.java
middle.gif How to Use Dialogs
DynamicTreeDemo [Launch] Dynamic Tree Demo Project DynamicTreeDemo.java
   DynamicTree.java
  How to Use Trees
FileChooserDemo * File Chooser Demo Project FileChooserDemo.java Open16.gif, Save16.gif How to Use File Choosers
FileChooserDemo2 * File Chooser 2 Demo Project FileChooserDemo2.java
   ImageFileView.java
   ImageFilter.java
   ImagePreview.java
   Utils.java
jpgIcon.gif, gifIcon.gif, tiffIcon.gif, pngIcon.png How to Use File Choosers
FormattedTextFieldDemo [Launch] Formatted Text Field Demo Project FormattedTextFieldDemo.java   How to Use Formatted Text Fields
FormatterFactoryDemo [Launch] Formatter Factory Demo Project FormatterFactoryDemo.java   How to Use Formatted Text Fields
FrameDemo [Launch] Frame Demo Project FrameDemo.java   How to Make Frames
FrameDemo2 [Launch] Frame 2 Demo Project FrameDemo2.java FD.jpg How to Make Frames
Framework [Launch] Framework Project Framework.java   Nowhere
GenealogyExample [Launch] Genealogy Example Project GenealogyExample.java
   GenealogyModel.java
   GenealogyTree.java
   Person.java
  How to Use Trees
GlassPaneDemo [Launch] Glass Pane Demo Project GlassPaneDemo.java   How to Use Root Panes
HtmlDemo [Launch] Html Demo Project HtmlDemo.java   Using HTML in Swing Components
IconDemo [Launch] Icon Demo Project IconDemoApp.java
MissingIcon.java
sunw01.jpg, sunw02.jpg, sunw03.jpg, sunw04.jpg, sunw05.jpg How to Use Icons
InternalFrameDemo [Launch] Internal Frame Demo Project InternalFrameDemo.java
   MyInternalFrame.java
  How to Use Internal Frames
JWSFileChooserDemo [Launch] JWS File Chooser Demo Project JWSFileChooserDemo.java Open16.gif, Save16.gif How to Use File Choosers
LabelDemo [Launch] Label Demo Project LabelDemo.java middle.gif How to Use Labels
LayeredPaneDemo [Launch] Layered Pane Demo Project LayeredPaneDemo.java dukeWaveRed.gif How to Use Layered Panes
LayeredPaneDemo2 [Launch] Layered Pane 2 Demo Project LayeredPaneDemo2.java dukeWaveRed.gif How to Use Layered Panes
ListDemo [Launch] List Demo Project ListDemo.java   How to Use Lists
ListDialogRunner [Launch] List Dialog Runner Project ListDialogRunner.java
   ListDialog.java
  How to Use Buttons, ...
MenuDemo [Launch] Menu Demo Project MenuDemo.java middle.gif How to Use Menus
MenuGlueDemo [Launch] Menu Glue Demo Project MenuGlueDemo.java   How to Use Menus
MenuLayoutDemo [Launch] Menu Layout Demo Project MenuLayoutDemo.java   How to Use Menus
MenuLookDemo [Launch] Menu Look Demo Project MenuLookDemo.java middle.gif How to Use Menus
MenuSelectionManagerDemo [Launch] Menu Selection Manager Demo Project MenuSelectionManagerDemo.java middle.gif How to Use Menus
PasswordDemo [Launch] Password Demo Project PasswordDemo.java   How to Use Password Fields
PopupMenuDemo [Launch] Popup Menu Demo Project PopupMenuDemo.java middle.gif How to Use Menus
ProgressBarDemo [Launch] Progress Bar Demo Project ProgressBarDemo.java   How to Monitor Progress
ProgressBarDemo2 [Launch] Progress Bar 2 Demo Project ProgressBarDemo2.java   How to Monitor Progress
ProgressMonitorDemo [Launch] Progress Monitor Demo Project ProgressMonitorDemo.java   How to Monitor Progress
RadioButtonDemo [Launch] Radio Button Demo Project RadioButtonDemo.java Bird.gif, Cat.gif, Dog.gif, Rabbit.gif, Pig.gif How to Use Buttons, ...
RootLayeredPaneDemo [Launch] Root Layered Pane Demo Project RootLayeredPaneDemo.java dukeWaveRed.gif How to Use Root Panes
ScrollDemo [Launch] Scroll Demo Project ScrollDemo.java
   Rule.java
   Corner.java
   ScrollablePicture.java
youngdad.jpeg How to Use Scroll Panes
ScrollDemo2 [Launch] Scroll 2 Demo Project ScrollDemo2.java   How to Use Scroll Panes
SharedModelDemo [Launch] Shared Model Demo Project SharedModelDemo.java
  Using Models
SimpleTableDemo [Launch] Simple Table Demo Project SimpleTableDemo.java   How to Use Tables
SimpleTableSelectionDemo [Launch] Simple Table Selection Demo Project SimpleTableSelectionDemo.java   How to Use Tables
SliderDemo [Launch] Slider Demo Project SliderDemo.java All of the images in the images/doggy directory. How to Use Sliders
SliderDemo2 [Launch] Slider 2 Demo Project SliderDemo2.java All of the images in the images/doggy directory. How to Use Sliders
SpinnerDemo [Launch] Spinner Demo Project SpinnerDemo.java
   SpringUtilities.java
   CyclingSpinnerListModel.java
  How to Use Spinners
SpinnerDemo2 [Launch] Spinner 2 Demo Project SpinnerDemo2.java
   SpinnerDemo.java
   SpringUtilities.java
   CyclingSpinnerListModel.java
  How to Use Spinners
SpinnerDemo3 [Launch] Spinner Demo 3 Project SpinnerDemo3.java
   SpringUtilities.java
   CyclingSpinnerListModel.java
  How to Use Spinners
SpinnerDemo4 [Launch] Spinner Demo 4 Project SpinnerDemo4.java
   SpringUtilities.java
  How to Use Spinners
SplitPaneDemo [Launch] Split Pane Demo Project SplitPaneDemo.java image files How to Use Split Panes
SplitPaneDemo2 [Launch] Split Pane 2 Demo Project SplitPaneDemo2.java image files How to Use Split Panes
SplitPaneDividerDemo [Launch] Split Pane Divider Demo Project SplitPaneDividerDemo.java
   SizeDisplayer.java
Cat.gif, Dog.gif How to Use Split Panes
TabbedPaneDemo [Launch] Tabbed Pane Demo Project TabbedPaneDemo.java middle.gif How to Use Tabbed Panes
TabComponentsDemo [Launch] Tab Components Demo Project TabComponentsDemo.java
   ButtonTabComponent.java
  How to Use Tabbed Panes
TableDemo [Launch] Table Demo Project TableDemo.java   How to Use Tables
TableDialogEditDemo [Launch] Table Dialog Edit Demo Project TableDialogEditDemo.java
   ColorEditor.java
   ColorRenderer.java
  How to Use Tables
TableFTFEditDemo [Launch] Table FTF Edit Demo Project TableFTFEditDemo.java
   IntegerEditor.java
  How to Use Tables
TableFilterDemo [Launch] Table Filter Demo Project TableFilterDemo.java
   SpringUtilities.java
  How to Use Tables
TablePrintDemo [Launch] Table Print Demo Project TablePrintDemo.java   How to Use Tables
TableRenderDemo [Launch] Table Render Demo Project TableRenderDemo.java   How to Use Tables
TableSelectionDemo [Launch] Table Selection Demo Project TableSelectionDemo.java   How to Use Tables
TableSortDemo [Launch] Table Sort Demo Project TableSortDemo.java   How to Use Tables
TableToolTipsDemo [Launch] Table Tool Tips Demo Project TableToolTipsDemo.java   How to Use Tables
TextAreaDemo [Launch] Text Area Demo Project TextAreaDemo.java   How to Use Text Areas
TextComponentDemo [Launch] Text Component Demo Project TextComponentDemo.java
   DocumentSizeFilter.java
  Text Component Features
TextDemo [Launch] Text Demo Project TextDemo.java   How to Use Text Fields and How to Use Text Areas
TextFieldDemo [Launch] Text Field Demo Project TextFieldDemo.java content.txt How to Use Text Fields
TextInputDemo [Launch] Text Input Demo Project TextInputDemo.java
   SpringUtilities.java
  How to Use Formatted Text Fields
TextSamplerDemo [Launch] Text Sampler Demo Project TextSamplerDemo.java Pig.gif, sound.gif, dukeWaveRed.gif, TextSamplerDemoHelp.html Using Text Components and How to Use Editor Panes and Text Panes
ToolBarDemo [Launch] Tool Bar Demo Project ToolBarDemo.java Back24.gif, Forward24.gif, Up24.gif How to Use Tool Bars
ToolBarDemo2 [Launch] Tool Bar 2 Demo Project ToolBarDemo2.java Back24.gif, Forward24.gif, Up24.gif How to Use Tool Bars
TopLevelDemo [Launch] Top Level Demo Project TopLevelDemo.java   Using Top-Level Containers
TreeDemo [Launch] Tree Demo Project TreeDemo.java Several html files. How to Use Trees
TreeIconDemo [Launch] Tree Icon Demo Project TreeIconDemo.java middle.gif and several html files. How to Use Trees
TreeIconDemo2 [Launch] Tree Icon 2 Demo Project TreeIconDemo2.java middle.gif and several html files. How to Use Trees
TumbleItem Tumble Item Project TumbleItem.java (an applet) All of the images in the images/tumble directory. How to Make Applets
* This application is not currently available with Java Web Start because we distribute only unsigned JAR files. To run it, download and compile it, and then run it as an application.

Geek Images

geek-----.gif, geek-c---.gif, geek--g--.gif, geek---h-.gif,
geek----t.gif, geek-cg--.gif, geek-c-h-.gif, geek-c--t.gif,
geek--gh-.gif, geek--g-t.gif, geek---h-.gif, geek-cg-t.gif,
geek-cgh-.gif, geek-c-ht.gif, geek--ght.gif, geek-cght.gif

Doggy Images

T0.gif, T1.gif, T2.gif, T3.gif, T4.gif, T5.gif, T6.gif,
T7.gif, T8.gif, T9.gif, T10.gif, T11.gif, T12.gif, T13.gif

Tumble Images

T1.gif, T2.gif, T3.gif, T4.gif, T5.gif,
T6.gif, T7.gif, T8.gif, T9.gif, T10.gif,
T11.gif, T12.gif, T13.gif, T14.gif, T15.gif,
T16.gif, T17.gif

Images used in SplitPaneDemo and SplitPaneDemo2

Bird.gif, Cat.gif, Dog.gif, Rabbit.gif, Pig.gif, dukeWaveRed.gif, kathyCosmo.gif, lainesTongue.gif, left.gif, middle.gif, right.gif, stickerface.gif

HTML Files Required for Tree Demos

TreeDemoHelp.html
arnold.html
bloch.html
chanlee.html
jls.html
swingtutorial.html
tutorial.html
tutorialcont.html
vm.html

Problems with the examples? Try Compiling and Running the Examples: FAQs.
Complaints? Compliments? Suggestions? Give us your feedback.

Previous page:
Next page: