Movatterモバイル変換


[0]ホーム

URL:


Documentation

The Java™ Tutorials
Trail: Creating a GUI with Swing
Lesson: Using Swing Components
Home Page >Creating a GUI with Swing >Using Swing Components
« Previous • Trail • Next »

The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.
SeeDev.java for updated tutorials taking advantage of the latest releases.
SeeJava Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.
SeeJDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.

Using Swing Components: Examples

Thetable 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 7.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 thetable. 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 toRunning 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 acomponents package. See the following image for the complete structure. Note that any examples using images expect their image files to be in a directory namedimages 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

ExampleZip 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 FilesWhere Described
BorderDemo[Launch]Border Demo ProjectBorderDemo.javawavy.gifHow to Use Borders
ButtonDemo[Launch]Button Demo ProjectButtonDemo.javaright.gif,middle.gif,left.gifHow to Use Buttons,...
ButtonHtmlDemo[Launch]Button Html Demo ProjectButtonHtmlDemo.javaright.gif,middle.gif,left.gifHow to Use Buttons,...
CheckBoxDemo[Launch]Check Box Demo ProjectCheckBoxDemo.javaAll of the images in theimages/geek directory.How to Use Buttons,...
ColorChooserDemo[Launch]Color Chooser Demo ProjectColorChooserDemo.java How to Use Color Choosers
ColorChooserDemo2[Launch]Color Chooser 2 Demo ProjectColorChooserDemo2.java
  CrayonPanel.java
red.gif,yellow.gif,green.gif,blue.gifHow to Use Color Choosers
ComboBoxDemo[Launch]Combo Box Demo ProjectComboBoxDemo.javaBird.gif,Cat.gif,Dog.gif,Rabbit.gif,Pig.gifHow to Use Combo Boxes
ComboBoxDemo2[Launch]Combo Box 2 Demo ProjectComboBoxDemo2.java How to Use Combo Boxes
Converter[Launch]Converter ProjectConverter.java
  ConversionPanel.java
  ConverterRangeModel.java
  FollowerRangeModel.java
  Unit.java
 How to Use Panels;
Using Models
CustomComboBoxDemo[Launch]Custom Combo Box Demo ProjectCustomComboBoxDemo.javaBird.gif,Cat.gif,Dog.gif,Rabbit.gif,Pig.gifHow to Use Combo Boxes
CustomIconDemo[Launch]Custom Icon Demo ProjectCustomIconDemo.java
  ArrowIcon.java
middle.gifHow to Use Icons
DialogDemo[Launch]Dialog Demo ProjectDialogDemo.java
  CustomDialog.java
middle.gifHow to Use Dialogs
DynamicTreeDemo[Launch]Dynamic Tree Demo ProjectDynamicTreeDemo.java
  DynamicTree.java
 How to Use Trees
FileChooserDemo*File Chooser Demo ProjectFileChooserDemo.javaOpen16.gif,Save16.gifHow to Use File Choosers
FileChooserDemo2*File Chooser 2 Demo ProjectFileChooserDemo2.java
  ImageFileView.java
  ImageFilter.java
  ImagePreview.java
  Utils.java
jpgIcon.gif,gifIcon.gif,tiffIcon.gif,pngIcon.pngHow to Use File Choosers
FormattedTextFieldDemo[Launch]Formatted Text Field Demo ProjectFormattedTextFieldDemo.java How to Use Formatted Text Fields
FormatterFactoryDemo[Launch]Formatter Factory Demo ProjectFormatterFactoryDemo.java How to Use Formatted Text Fields
FrameDemo[Launch]Frame Demo ProjectFrameDemo.java How to Make Frames
FrameDemo2[Launch]Frame 2 Demo ProjectFrameDemo2.javaFD.jpgHow to Make Frames
Framework[Launch]Framework ProjectFramework.java Nowhere
GenealogyExample[Launch]Genealogy Example ProjectGenealogyExample.java
  GenealogyModel.java
  GenealogyTree.java
  Person.java
 How to Use Trees
GlassPaneDemo[Launch]Glass Pane Demo ProjectGlassPaneDemo.java How to Use Root Panes
HtmlDemo[Launch]Html Demo ProjectHtmlDemo.java Using HTML in Swing Components
IconDemo[Launch]Icon Demo ProjectIconDemoApp.java
MissingIcon.java
sunw01.jpg,sunw02.jpg,sunw03.jpg,sunw04.jpg,sunw05.jpgHow to Use Icons
InternalFrameDemo[Launch]Internal Frame Demo ProjectInternalFrameDemo.java
  MyInternalFrame.java
 How to Use Internal Frames
JWSFileChooserDemo[Launch]JWS File Chooser Demo ProjectJWSFileChooserDemo.javaOpen16.gif,Save16.gifHow to Use File Choosers
LabelDemo[Launch]Label Demo ProjectLabelDemo.javamiddle.gifHow to Use Labels
LayeredPaneDemo[Launch]Layered Pane Demo ProjectLayeredPaneDemo.javadukeWaveRed.gifHow to Use Layered Panes
LayeredPaneDemo2[Launch]Layered Pane 2 Demo ProjectLayeredPaneDemo2.javadukeWaveRed.gifHow to Use Layered Panes
ListDemo[Launch]List Demo ProjectListDemo.java How to Use Lists
ListDialogRunner[Launch]List Dialog Runner ProjectListDialogRunner.java
  ListDialog.java
 How to Use Buttons,...
MenuDemo[Launch]Menu Demo ProjectMenuDemo.javamiddle.gifHow to Use Menus
MenuGlueDemo[Launch]Menu Glue Demo ProjectMenuGlueDemo.java How to Use Menus
MenuLayoutDemo[Launch]Menu Layout Demo ProjectMenuLayoutDemo.java How to Use Menus
MenuLookDemo[Launch]Menu Look Demo ProjectMenuLookDemo.javamiddle.gifHow to Use Menus
MenuSelectionManagerDemo[Launch]Menu Selection Manager Demo ProjectMenuSelectionManagerDemo.javamiddle.gifHow to Use Menus
PasswordDemo[Launch]Password Demo ProjectPasswordDemo.java How to Use Password Fields
PopupMenuDemo[Launch]Popup Menu Demo ProjectPopupMenuDemo.javamiddle.gifHow to Use Menus
ProgressBarDemo[Launch]Progress Bar Demo ProjectProgressBarDemo.java How to Monitor Progress
ProgressBarDemo2[Launch]Progress Bar 2 Demo ProjectProgressBarDemo2.java How to Monitor Progress
ProgressMonitorDemo[Launch]Progress Monitor Demo ProjectProgressMonitorDemo.java How to Monitor Progress
RadioButtonDemo[Launch]Radio Button Demo ProjectRadioButtonDemo.javaBird.gif,Cat.gif,Dog.gif,Rabbit.gif,Pig.gifHow to Use Buttons,...
RootLayeredPane[Launch]Root Layered Pane Demo ProjectRootLayeredPaneDemo.javadukeWaveRed.gifHow to Use Root Panes
ScrollDemo[Launch]Scroll Demo ProjectScrollDemo.java
  Rule.java
  Corner.java
  ScrollablePicture.java
flyingBee.jpgHow to Use Scroll Panes
ScrollDemo2[Launch]Scroll 2 Demo ProjectScrollDemo2.java How to Use Scroll Panes
SharedModelDemo[Launch]Shared Model Demo ProjectSharedModelDemo.java
 Using Models
SimpleTableDemo[Launch]Simple Table Demo ProjectSimpleTableDemo.java How to Use Tables
SimpleTableSelectionDemo[Launch]Simple Table Selection Demo ProjectSimpleTableSelectionDemo.java How to Use Tables
SliderDemo[Launch]Slider Demo ProjectSliderDemo.javaAll of the images in theimages/doggy directory.How to Use Sliders
SliderDemo2[Launch]Slider 2 Demo ProjectSliderDemo2.javaAll of the images in theimages/doggy directory.How to Use Sliders
SpinnerDemo[Launch]Spinner Demo ProjectSpinnerDemo.java
  SpringUtilities.java
  CyclingSpinnerListModel.java
 How to Use Spinners
SpinnerDemo2[Launch]Spinner 2 Demo ProjectSpinnerDemo2.java
  SpinnerDemo.java
  SpringUtilities.java
  CyclingSpinnerListModel.java
 How to Use Spinners
SpinnerDemo3[Launch]Spinner Demo 3 ProjectSpinnerDemo3.java
  SpringUtilities.java
  CyclingSpinnerListModel.java
 How to Use Spinners
SpinnerDemo4[Launch]Spinner Demo 4 ProjectSpinnerDemo4.java
  SpringUtilities.java
 How to Use Spinners
SplitPaneDemo[Launch]Split Pane Demo ProjectSplitPaneDemo.javaimage filesHow to Use Split Panes
SplitPaneDemo2[Launch]Split Pane 2 Demo ProjectSplitPaneDemo2.javaimage filesHow to Use Split Panes
SplitPaneDividerDemo[Launch]Split Pane Divider Demo ProjectSplitPaneDividerDemo.java
  SizeDisplayer.java
Cat.gif,Dog.gifHow to Use Split Panes
TabbedPaneDemo[Launch]Tabbed Pane Demo ProjectTabbedPaneDemo.javamiddle.gifHow to Use Tabbed Panes
TabComponentsDemo[Launch]Tab Components Demo ProjectTabComponentsDemo.java
  ButtonTabComponent.java
 How to Use Tabbed Panes
TableDemo[Launch]Table Demo ProjectTableDemo.java How to Use Tables
TableDialogEditDemo[Launch]Table Dialog Edit Demo ProjectTableDialogEditDemo.java
  ColorEditor.java
  ColorRenderer.java
 How to Use Tables
TableFTFEditDemo[Launch]Table FTF Edit Demo ProjectTableFTFEditDemo.java
  IntegerEditor.java
 How to Use Tables
TableFilterDemo[Launch]Table Filter Demo ProjectTableFilterDemo.java
  SpringUtilities.java
 How to Use Tables
TablePrintDemo[Launch]Table Print Demo ProjectTablePrintDemo.java How to Use Tables
TableRenderDemo[Launch]Table Render Demo ProjectTableRenderDemo.java How to Use Tables
TableSelectionDemo[Launch]Table Selection Demo ProjectTableSelectionDemo.java How to Use Tables
TableSortDemo[Launch]Table Sort Demo ProjectTableSortDemo.java How to Use Tables
TableToolTipsDemo[Launch]Table Tool Tips Demo ProjectTableToolTipsDemo.java How to Use Tables
TextAreaDemo[Launch]Text Area Demo ProjectTextAreaDemo.java How to Use Text Areas
TextComponentDemo[Launch]Text Component Demo ProjectTextComponentDemo.java
  DocumentSizeFilter.java
 Text Component Features
TextDemo[Launch]Text Demo ProjectTextDemo.java How to Use Text Fields andHow to Use Text Areas
TextFieldDemo[Launch]Text Field Demo ProjectTextFieldDemo.javacontent.txtHow to Use Text Fields
TextInputDemo[Launch]Text Input Demo ProjectTextInputDemo.java
  SpringUtilities.java
 How to Use Formatted Text Fields
TextSamplerDemo[Launch]Text Sampler Demo ProjectTextSamplerDemo.javaPig.gif,sound.gif,dukeWaveRed.gif,TextSamplerDemoHelp.htmlUsing Text Components andHow to Use Editor Panes and Text Panes
ToolBarDemo[Launch]Tool Bar Demo ProjectToolBarDemo.javaBack24.gif,Forward24.gif,Up24.gifHow to Use Tool Bars
ToolBarDemo2[Launch]Tool Bar 2 Demo ProjectToolBarDemo2.javaBack24.gif,Forward24.gif,Up24.gifHow to Use Tool Bars
TopLevelDemoProject[Launch]Top Level Demo ProjectTopLevelDemo.java Using Top-Level Containers
TreeDemo[Launch]Tree Demo ProjectTreeDemo.javaSeveralhtml files.How to Use Trees
TreeIconDemo[Launch]Tree Icon Demo ProjectTreeIconDemo.javamiddle.gif and severalhtml files.How to Use Trees
TreeIconDemo2[Launch]Tree Icon 2 Demo ProjectTreeIconDemo2.javamiddle.gif and severalhtml files.How to Use Trees
TumbleItemTumble Item ProjectTumbleItem.java(an applet)All of the images in theimages/tumble directory.How to Make Applets

* This application is not currently available with Java Web Start. 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

« PreviousTrailNext »

About Oracle |Contact Us |Legal Notices |Terms of Use |Your Privacy Rights

Copyright © 1995, 2024 Oracle and/or its affiliates. All rights reserved.

Previous page:
Next page:

[8]ページ先頭

©2009-2025 Movatter.jp