Containers hold and manage other components. When you layout a form to design the UI in JDeveloper you use containers. There are two general classes of containers:
Containers are also components; you interact with them by getting and setting their properties, calling their methods, and responding to their events as with any other component.
Windows
A Window is a stand-alone top-level container component with no borders, title bar, or menu bar. Although a Window could be used to implement a popup window, you normally use a subclass of Window in your UI such as one of those listed below.
Window | Description |
---|---|
Frame |
A top-level window with a border and a title. A Frame has standard window controls such as a control menu, buttons to minimize and maximize the window, and controls for resizing the window. It can also contain a menu bar. |
Dialog Box |
A popup window, similar to a Frame, but it needs a parent. Dialog boxes are used for getting input from the user or to present warning messages. It can also contain a menu bar. Dialog boxes are usually intended to be transient, or temporary, and can be one of the following types: Modal: Prevents user input to any other windows in the application until that dialog box is dismissed. Modeless: Lets the user enter information in both the dialog box and the application. |
Panels
A Panel is a simple UI container, without border or caption, used to group other components, like buttons, checkboxes, and text fields. Panels are embedded within some other UI, such as in a frame or dialog. They can also be nested within other panels.
Panel | Description |
---|---|
Applet |
A subclass of Panel used to build a program intended to be embedded in an HTML page and run in an Internet browser or applet viewer. Since Applet is a subclass of Panel, it can contain components, but does not have a border or caption. |
Lightweight Swing Containers
The lightweight Swing containers available from JDeveloper's Component Palette pages include JMenuBar, JPopupMenu, JSplitPane, JScrollPane, JTabbedPane, and JToolbar. All are a subclass of JComponent. You can add other containers and components to these containers, combining components and their containers in various ways to get the interface you want.
Lightweight Container | Description |
---|---|
Menu Bar |
In JDeveloper you use the Menu Editor to add menus to the menu bar to construct a menu. When the user selects a JMenu object, its associated JPopupMenu is displayed, allowing the user to select one of the JMenuItems on it. |
Popup Menu |
A small window which pops up and displays a series of choices, which you create in JDeveloper using the Menu Editor. A JPopupMenu is used for the menu that appears when the user selects an item on the menu bar. It is also used for "pull-right" menu that appears when the selects a menu item that activates it. Finally, a JPopupMenu can also be used anywhere else you want a menu to appear -- for example, when the user right-clicks in a specified area. |
Split Pane |
Manages two panes that are separated horizontally or vertically by
a divider that can be repositioned by the user. You can choose
which pane to add a component to. You can specify the components
with the properties |
Scroll Pane |
Consists of JScrollBars, a JViewport. The JViewPort provides a window, or "viewport" onto a data source -- for example, a text file. That data source is the "scrollable client" (or data model) displayed by the JViewport view. The scrollable client can be any component, but when you drop the component from the Component Palette, rather than "adding" it to the JScrollPane container, JDeveloper specifies it as part of the constructor.
Along with its scroll bars and viewport, a JScrollPane can have a
column header and a row header. Each of these is a JViewport
object that you specify with
To add a border around the main viewport, you can use the |
Tabbed Pane |
Manages multiple panels that completely overlap each other. The
user can select a panel to view by clicking on a "tab" attached to
the panel (like the tab on a file folder). You add tabs in
JDeveloper by dropping a JPanel onto the tabbed pane from the
Component Palette. The |
Toolbar |
Provides a component which is useful for displaying commonly used
Actions or controls. It can be dragged out into a separate window
by the user (unless the |
For more information on Swing containers, go to this Sun Microsystems web page:
http://java.sun.com/products/jfc/tsc/articles/containers/index.html
For more information on Swing components, go to this Sun Microsystems web page:
http://java.sun.com/products/jfc/tsc/articles/component_gallery/index.html
Creating Containers
Working with Components in a Container
Working with Menus
Working with Applets
Working with Layout Managers
Prototyping the UI Using Layout Properties
Copyright © 1997, 2004, Oracle. All rights reserved.