Wednesday, February 10, 2010

Using Swing Components

Lesson: Using Swing Components
Examples Index

This lesson gives you the background information you need to use the Swing components, and then describes every Swing component. It assumes that you have successfully compiled and run a program that uses Swing components, and that you are familiar with basic Swing concepts. These prerequisites are covered in Getting Started with Swing and Learning Swing with the NetBeans IDE.

A Visual Index to the Swing Components (Java Look and Feel)
A Visual Index to the Swing Components (Windows Look and Feel)

Before you get started, you may want to check out these pages (from the Graphical User Interfaces lesson in the Core trail) which have pictures of all the standard Swing components, from top-level containers to scroll panes to buttons. To find the section that discusses a particular component, just click the component's picture.

Using Top-Level Containers

Discusses how to use the features shared by the JFrame, JDialog, and JApplet classes — content panes, menu bars, and root panes. It also discusses the containment hierarchy, which refers to the tree of components contained by a top-level container.

The JComponent Class

Tells you about the features JComponent provides to its subclasses — which include almost all Swing components — and gives tips on how to take advantage of these features. This section ends with API tables describing the commonly used API defined by JComponent and its superclasses,Container and Component.

Using Text Components

Describes the features and API shared by all components that descend from JTextComponent. You probably do not need to read this section if you are just using text fields (formatted or not) or text areas.

How to...

Sections on how to use each Swing component, in alphabetical order. We do not expect you to read these sections in order. Instead, we recommend reading the relevant "How to" sections once you are ready to start using Swing components in your own programs. For example, if your program needs a frame, a label, a button, and a color chooser, you should read How to Make Frames, How to Use Labels, How to Use Buttons, and How to Use Color Choosers.

Using HTML in Swing Components

Describes how to vary the font, color, or other formatting of text displayed by Swing components by using HTML tags.

Using Models

Tells you about the Swing model architecture. This variation on Model-View-Controller (MVC) means that you can, if you wish, specify how the data and state of a Swing component are stored and retrieved. The benefits are the ability to share data and state between components, and to greatly improve the performance of components such as tables that display large amounts of data.

Using Borders

Borders are very handy for drawing lines, titles, and empty space around the edges of components. (You might have noticed that the examples in this trail use a lot of borders.) This section tells you how to add a border to any JComponent.

Using Icons

Many Swing components can display icons. Usually, icons are implemented as instances of the ImageIcon class.

Solving Common Component Problems

This section discusses solutions to common component-related problems.

Questions and Exercises

Try these questions and exercises to test what you have learned in this lesson.

We welcome your participation in our community. Please keep your comments civil and on point. You may optionally provide your email address to be notified of replies — your information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.

Echo 6 Items
Admin
lester
hi
Sunday, August 02, 2009, 03:43:10
FlagLikeReply
Guest
hello,
im tring to find a code for a simple date chooser.
i need to get dates from my users that will be formatted like this- dd/mm/yyyy

thank u
Monday, August 24, 2009, 19:01:30
FlagLikeReply
Prasant
This is very helpful site for learning latest java programming.
im very thankful to sun.
Saturday, October 03, 2009, 16:08:23
FlagLikeReply
KingNiNe
Hi~
Monday, November 16, 2009, 03:09:02
FlagLikeReply
Tirunelveli
fine la...
Monday, December 21, 2009, 07:46:30
FlagLikeReply
Rakesh Singh
it's excellent for beginners to learn JAVA.
Iwould like to recomment that there should be downloading facility too.
Wednesday, January 13, 2010, 10:25:22
FlagLikeReply

No comments:

Post a Comment