How Do These Concepts Translate into Code?

Visual Index to Swing Components

Now that you've gotten a taste of how to build your own Swing programs, this section gives a quick, visual reference of the Swing components so you can find more information online and on the CD. The components are broken down into six categories: top-level containers, general-purpose containers, special-purpose containers, basic controls, uneditable information displays, and editable displays of formatted information.

Table 52. Top-Level Containers: The components at the top of any Swing containment hierarchy

Component

URLs

Applet

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JApplet.html

Dialog

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JDialog.html

Frame

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JFrame.html

Table 53. General-Purpose Containers: Intermediate containers that can be used under many different circumstances

Component

URLs

Panels

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/panel.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JPanel.html

Scroll Pane

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JScrollPane.html

Split Pane

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/splitpane.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JSplitPane.html

Tabbed Pane

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTabbedPane.html

Tool Bar

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/toolbar.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JToolBar.html

Table 54. Special-Purpose Containers: Intermediate containers that play specific roles in the UI

Components

URLs

Internal Frames

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JInternalFrame.html

Layered Panes

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JLayeredPane.html

Root Pane (representation)

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JRootPane.html

Table 55. Basic Controls: Atomic components that exist primarily to get input from the user and that generally also show simple state

Components

URLs

Buttons

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/button.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JButton.html

Combo Box

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JComboBox.html

List

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/list.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JList.html

Menu

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JMenu.html

Slider

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JSlider.html

Text Fields

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTextField.html

Table 56. Uneditable Information Displays: Atomic components that exist solely to give the user information

Components

URLs

Label

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/label.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JLabel.html

Progress Bar

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JProgressBar.html

Tool Tip

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/tooltip.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JToolTip.html

Table 57. Editable Displays of Formatted Information: Atomic components that display highly formatted information that (if you choose) can be edited by the user

Components

URLs

Color Chooser

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/colorchooser.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JColorChooser.html

File Chooser

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JFileChooser.html

Table

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTable.html

Text

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/text/JTextComponent.html

Tree

The Java Tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html

API Documentation:

http://java.sun.com/j2se/1.3/docs/api/javax/swing/JTree.html

Категории