The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search

Trail: Creating a GUI with JFC/Swing
Lesson: Using Swing Components

Using Swing Components: Examples


Note: Examples are applications unless noted otherwise.

For most examples, place the image files in a directory named images in the same directory as the source and class files for the example. For example, here's the setup for ButtonDemo:

                 a directory
                      |
          +-----------+-----------+
          |                       |
      ButtonDemo*               images
                                  |   
                     +------------+------------+
                     |            |            | 
                 left.gif      middle.gif   right.gif
[PENDING: draw real figure instead of ASCII figure]

Some examples, such as CheckBoxDemo and SliderDemo, require the image files to be in a sub-directory of the images directory.

Source Files Image & Other Files Where Described
ButtonDemo.java right.gif, middle.gif, left.gif How to Use Buttons, ...
CheckBoxDemo.java All of the images in the images/geek directory. How to Use Buttons, ...
ColorChooserDemo.java   How to Use Color Choosers
ColorChooserDemo2.java
  CrayonPanel.java
red.gif, yellow.gif, green.gif, blue.gif How to Use Color Choosers
ComboBoxDemo.java Bird.gif, Cat.gif, Dog.gif, Rabbit.gif, Pig.gif How to Use Combo Boxes
ComboBoxDemo2.java   How to Use Combo Boxes
CustomComboBoxDemo.java Bird.gif, Cat.gif, Dog.gif, Rabbit.gif, Pig.gif How to Use Combo Boxes
DialogDemo.java
  CustomDialog.java
middle.gif How to Use Dialogs
DynamicTreeDemo.java
  DynamicTree.java
  How to Use Trees
FileChooserDemo.java open.gif, save.gif How to Use File Choosers
FileChooserDemo2.java
  ImageFileView.java
  ImageFilter.java
  ImagePreview.java
  Utils.java
jpgIcon.gif, gifIcon.gif, tiffIcon.gif How to Use File Choosers
FrameDemo.java   How to Make Frames
Framework.java   Nowhere
GenealogyExample.java
  GenealogyModel.java
  GenealogyTree.java
  Person.java
  How to Use Trees
GlassPaneDemo.java   How to Use Root Panes
HtmlDemo.java   How to Use Labels
InternalFrameDemo.java
  MyInternalFrame.java
  How to Use Internal Frames
LabelDemo.java middle.gif How to Use Labels
LayeredPaneDemo.java dukeWaveRed.gif How to Use Layered Panes
LayeredPaneDemo2.java dukeWaveRed.gif How to Use Layered Panes
ListDemo.java   How to Use Lists
ListDialog.java   How to Use Buttons, ...
MenuLookDemo.java middle.gif How to Use Menus
MenuDemo.java middle.gif How to Use Menus
MenuGlueDemo.java   How to Use Menus
MenuLayoutDemo.java   How to Use Menus
PasswordDemo.java   How to Use Text Fields
PopupMenuDemo.java middle.gif How to Use Menus
ProgressBarDemo.java
  LongTask.java
  SwingWorker.java
  How to Monitor Progress
ProgressMonitorDemo.java
  LongTask.java
  SwingWorker.java
  How to Monitor Progress
RadioButtonDemo.java Bird.gif, Cat.gif, Dog.gif, Rabbit.gif, Pig.gif How to Use Buttons, ...
ScrollDemo.java
  Rule.java
  Corner.java
  ScrollablePicture.java
youngdad.jpeg How to Use Scroll Panes
ScrollDemo2.java   How to Use Scroll Panes
SharedModelDemo.java   Nowhere [PENDING: OK?]
SimpleTableDemo.java   How to Use Tables
SimpleTableSelectionDemo.java   How to Use Tables
SliderDemo.java All of the images in the images/doggy directory. How to Use Sliders
SliderDemo2.java All of the images in the images/doggy directory. How to Use Sliders
SplitPaneDemo.java imagenames.properties and all of the image files listed in it. How to Use Split Panes
SplitPaneDemo2.java imagenames.properties and all of the image files listed in it. How to Use Split Panes
TabbedPaneDemo.java middle.gif How to Use Tabbed Panes
TableDemo.java   How to Use Tables
TableEditDemo.java
  WholeNumberField.java
  How to Use Tables
TableDialogEditDemo.java
  WholeNumberField.java
  How to Use Tables
TableRenderDemo.java   How to Use Tables
TableSorterDemo.java
  TableMap.java
  TableSorter.java
  How to Use Tables
TextComponentDemo.java
  LimitedStyledDocument.java
  General Rules for Using Text Components
TextDemo.java (an applet) To run the applet: TextDemo.html
To view the <APPLET> tag: TextDemo.atag
How to Use Text Fields
TextFieldDemo.java
  DecimalField.java
  FormattedDocument.java
  WholeNumberField.java
  How to Use Text Fields
TextSamplerDemo.java Pig.gif, sound.gif, dukeWaveRed.gif, TextSamplerDemoHelp.html An Example of Using Each Text Component
ToolBarDemo.java right.gif, middle.gif, left.gif How to Use Tool Bars
ToolBarDemo2.java right.gif, middle.gif, left.gif How to Use Tool Bars
TopLevelDemo.java   Using Top-Level Containers
TreeDemo.java Several html files. How to Use Trees
TreeIconDemo.java middle.gif and several html files. How to Use Trees
TreeIconDemo2.java middle.gif and several html files. How to Use Trees
TumbleItem.java (an applet)
  SwingWorker.java
All of the images in the images/tumble directory.
To run the applet: TumbleItem.html
To view the <APPLET> tag: TumbleItem.atag
How to Make Applets

Geek Images

geek-----.gif, geek-c---.gif, geek--g--.gif, geek---h-.gif,
geek----g.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 listed in imagenames.properties

Bird.gif, Cat.gif, Dog.gif, Rabbit.gif, Pig.gif,
all.gif, blue.gif, doggy/T1.gif, dukeWaveRed.gif, geek/geek-cght.gif,
green.gif, kathyCosmo.gif, lainesTongue.gif, left.gif, middle.gif,
red.gif, right.gif, smallbabies.jpeg, sophie.gif, stickerface.gif,
tumble/T7.gif, yellow.gif, youngdad.jpeg,

HTML Files Required for Tree Demos

TreeDemoHelp.html
tutorial.html
tutorialcont.html
swingtutorial.html
arnold.html
faq.html
chanlee.html
thread.html
vm.html
jls.html

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search