PPT08_Graphical_User_Interfaces

PPT08_Graphical_User_Interfaces - Writing Graphical User...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Writing Graphical User Interfaces Understanding Java’s GUI Classes Java has two sets of GUI classes Original GUI class – AWT – Abstract Window Toolkit Located in java.awt package Updated GUI class – Swing Located in javax.swing Both contain classes to create controls Windows Push buttons Text fields Menus Style and appearance of GUI components are called their look and feel AWT classes adopt look and feel of the local platform With Swing you have the option of using local platform look and feel or a standard look and feel (called “metal”) Both AWT and Swing take advantage of inheritance AWT GUI Classes Applet Superclass of all Applets Button Push Button Checkbox A list of items to check CheckboxGroup Used to create radio buttons Choice Drop down list of items to choose from AWT GUI Classes Component Superclass of all GUI classes Container A component that can contain other components Frame A GUI window with a title bar Label Used to display text. No input List A list of items to select from AWT GUI Classes Panel A type of container TextArea A large display area TextField Used to display and input text Window Superclass of Frame Page 1 of 11
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Component Button Label Checkbox Choice List Container Panel Applet Window Frame TextComponent TextArea TextField CheckboxGroup Using AWT Classes Class definition of a GUI generally follows the structure you used for a problem domain class One difference is that you create an instance of GUI and make it visible Write statements to instantiate GUI components Then write statements to add them to the window Creating a Window with a Button A Frame is a Window which is a Container which is a Component. Need to import the AWT package: import java.awt.*; Your class must: Inherit from Frame Implement the Listener interfaces Override the interface methods Creating a Window with a Button Constructor must accomplish five tasks: Create an instance of Button Add the button to the frame Register the Listener Establish the frame size Place a title on the frame Make the frame visible Frame Class Constructor Summary Frame() Constructs a new instance of Frame that is initially invisible. Frame(String title) Constructs a new, initially invisible Frame object with the specified title. Frame Class Methods public void dispose() Inherited from Window public void setLayout(LayoutManager mgr) Sets the layout manager for this container. Inherited from Container public void setSize(int width, int height) Page 2 of 11
Background image of page 2
Resizes this component so that it has width width and height. Inherited from Component Void setTitle(String title) Sets the title for this frame to the specified string. public void setVisible(boolean b) Shows or hides this component depending on the value of parameter b. Inherited from Component
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/15/2010 for the course CSIS 345 taught by Professor Dwightstrong during the Spring '10 term at Pittsburg State Uiversity.

Page1 / 11

PPT08_Graphical_User_Interfaces - Writing Graphical User...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online