270 likes | 360 Vues
JAVA SWING. By Tahira Braschi April 20, 2001 Dr. Marchant CS 108-002. What is JFC?. JFC stands for Java Foundation Classes, and it includes a group of features to help people build GUIs (Graphical User Interfaces). Features which help defined JFC are: The Swing components
E N D
JAVA SWING By Tahira Braschi April 20, 2001 Dr. Marchant CS 108-002
What is JFC? • JFC stands for Java Foundation Classes, and it includes a group of features to help people build GUIs (Graphical User Interfaces). • Features which help defined JFC are: • The Swing components • Pluggable Look and Feel Support • Accessibility API (Application Programmer Interface) • Java 2D™ API • Drag and Drop Support
Swing • “Swing” is the codename of the project that developed the new components. It is not the official name. • However, it’s frequently used to refer to the new components and related API.
Swing Components… • Part of the Java™ Foundation Classes (JFC), and can be used with either JDK™ 1.1 or the Java™ 2 platform. • Include everything: buttons, lists, menus, tables, text areas, and containers such as windows and tool bars.
Top-Level Containers Applet—you should know that by now! Dialog—windows that are more limited than frames. Frame—is a window that has decorations such as a border, a title, and buttons for closing and iconifying the window. Applications with a GUI typically use at least one frame.
General-Purpose Containers • Intermediate containers which can be used under many different circumstances: • Panel • Scroll pane • Split pane • Tabbed pane • Tool bar
General Purpose Containers • Panel—most flexible and frequently used. Add almost no functionality beyond what all objects have. Often used to group components. • Scroll pane—provides scroll bars around a large or growable component. • Split pane—displays two components in a fixed amount of space, letting the user adjust the amount of space devoted to each component.
General Purpose Containers • Tabbed pane—contains multiple components but show only one at a time. The user can easily switch between components. • Tool bar—holds a group of components (usually buttons) in a row or column, optionally allowing the user to drag the tool bar into different locations.
General-Purpose Containers Panel Split pane Scroll Pane Tool bar Tabbed pane
Special-Purpose Containers • Intermediate containers that play specific roles in the use interface. • Internal frame— Able to display display a Frame-like window within another window. Usually, you add internal frames to a desktop pane. • Layered frame—Provides a third dimension for positioning components: depth, also known as Z order. • Root pane—Has 4 parts: glass pane, layered pane, content pane, and the (optional) menu bar.
Special-Purpose Containers Internal Frame Layered Pane Root Pane
Basic Controls • Atomic components that exist primarily to get input from the user; they generally also show simple state. • Buttons—can be square or round • Combo Box—can be uneditable and editable. • List—Presents the user with a group of items, displayed in a column, to choose from. • Menu—provides a space-saving way to let the user choose one of several options. • Slider—lets user enter a numeric value bounded by a minimum and maximum value. • Text Fields—basic text control that lets the user enter a small amount of text.
Basic Controls List Buttons Combo Box Slider Text Fields Menu
Uneditable Information Displays • Atomic components that exist solely to give the user information. • Label—able to display unselectable text and images. • Progress Bar—displays the progress of a long-running task (also, ProgressMonitor and ProgressMonitorInputStream) • Tool tip—comes up when the user of the program pauses with the cursor over any of the program's buttons
Uneditable Information Displays Progress Bar Label Tool Tips
Editable Displays of Formatted Information • Atomic components that display highly formatted information that can be edited by the user. • Color chooser—provide users with a palette of colors to choose from. • File chooser—provide a GUI for navigating the file system, and then either choosing a file or directory from a list or entering a file name or directory name. • Table—displays tables of data, optionally allowing the user to edit the data. • Text—displays text and allows user to edit it • Tree—displays data in hierarchical way
Editable Displays of Formatted Information File Chooser Color Chooser Tree Table Text
Pluggable Look & Feel Support • Gives any program that uses Swing components a choice of looks and feels. For example, the same program can use either the Java™ look-and-feel or the Windows look-and-feel. • Many more look-and-feel packages will be available in the future from various sources, including some that use sound instead of a visual “look.”
Pluggable Look & Feel Support Java Look-and-feel CDE/Motif Look-and-feel Windows Look-and-feel
Accessibility API • Enables assistive technologies such as screen readers and Braille displays (for blind people) to get information from the user interface. • Primarily, assistive technologies exist to enable people with permanent or temporary disabilities to use the computer. • For example, if you get carpal tunnel syndrome, you can use assistive technologies to accomplish your work without using your hands.
Java 2D™ API Java 2 Platform only • Enables developers to easily incorporate high-quality 2D graphics, text, and images in applications and in applets. • Enables you to display complex charts and graphs that use various line and fill styles to distinguish sets of data. • Enables you to store and to manipulate image data—by performing image-filter operations, such as blur and sharpen.
Drag and Drop Support • Java 2 Platform only • Provides the ability to drag and drop between a Java application and a native application.
For more information on … • Go to java.sun.com. This is a very useful site and it is where I got my information for this presentation • There’s a tutorial which takes you step by step on how to use Swing components.
Questions • What is JFC? • What is Swing? • Name the Swing components? • Name 3 general purpose containers of Swing? • What does the Pluggable look and feel support does?
Thank you!!! Thank you for your time! No, no questions, please!!!! …or else you’ll be running after class!