01-09-2012, 12:57 PM
AWT and Swing
AWTandSwing.ppt (Size: 1.17 MB / Downloads: 179)
Most GUI class libraries in C++ are platform specific
Different hardware capabilities
Subtle differences between the "look-and-feel" of various Windowing operating systems
Abstract Window Toolkit (AWT) is cross-platform
Swing can observe various OS look-and-feel conventions
Common functionality/specific implementation approach
AWT GUI classes are platform-independent elements
Each AWT platform-specific toolkit comes with peer class implementing platform-specific behavior of its AWT class
Combining platform-independent AWT class with platform-specific peer class transforms generic, abstract windows behavior into specific, particular behavior
Window and Frame classes
A Window is a top-level window with no borders and no menubar
It can generate a WindowOpened or a WindowClosed event,
to which a WindowListener or WindowAdapter can respond
A Frame is a top-level window with a title and a border
Because it has more features, it can generate more events:
WindowOpened, WindowClosing, WindowClosed,
WindowIconified, WindowDeiconified,
WindowActivated, WindowDeactivated
Respond to these events with a WindowListener
Once a subclass of Container has been constructed, it can add (attach) any AWT component within it, such as a Button, Label, TextField, or another Frame or Panel
Swing overview
Defined in package javax.swing
Original GUI components from AWT in java.awt
Heavyweight components - rely on local platform's windowing system for look and feel
Swing components are lightweight
Not weighed down by GUI capabilities of platform
More portable than heavyweight components
Swing components allow programmer to specify look and feel
Can change depending on platform
Can be same across all platforms