Presentation is loading. Please wait.

Presentation is loading. Please wait.

AWT Components (Chapter 9) Java Certification Study Group January 21, 1999 Mark Roth.

Similar presentations


Presentation on theme: "AWT Components (Chapter 9) Java Certification Study Group January 21, 1999 Mark Roth."— Presentation transcript:

1 AWT Components (Chapter 9) Java Certification Study Group January 21, 1999 Mark Roth

2

3 Components java.awt.Component –“A component is an object having a graphical representation that can be displayed on the screen and that can interact with the user.” - Javadoc java.awt.MenuComponent –“The abstract class MenuComponent is the superclass of all menu-related components.” - Javadoc

4 java.awt.Compoennt Dimension getSize() void setForeground( java.awt.Color ) void setBackground( java.awt.Color ) setFont( java.awt.Font ) setEnabled( boolean ) setSize( width, height ) These Only Work Well for Frames: –setBounds( Rectangle ) or (x, y, w, h) –setVisible( boolean )

5 Component Categories (11) Visual Components (4) Container Components (4) Menu Components

6 Visual Components “…the ones that users can actually see and interact with.” - S. Roberts To Use: –Create a new instance –Add component to a container

7 Constructing Visual Components Button( String label ) --> ActionEvent Canvas() --> MouseEvent, MouseMotionEvent, KeyEvent Checkbox( String label, boolean initialState ) --> ItemEvent Choice() --> ItemEvent FileDialog( Frame parent, String title, int mode ) Label( String text, int alignment )

8 Constructing Visual Components List( int nVisibleRows, boolean multiSelectOk ) --> ItemEvent, ActionEvent ScrollPane( int scrollbarPolicy ) --> MouseEvent, MouseMotionEvent Scrollbar( int orientation, int initialValue, int sliderSize, int minValue, int maxValue ) --> AdjustmentEvent

9 Constructing Visual TextComponents TextField( String text, int nCols ) TextArea( String text, int nRows, int nCols, int scrollbarPolicy ) Events –TextEvent (both, when text is typed) –ActionEvent (Enter in TextField)

10 Constructing Container Components Applet() Frame( String title ) Panel() Dialog()

11 Menu Components Creation –Create a menu bar and attach it to the frame. –Create and populate the menu. –Attach the menu to the menu bar. Populating the Menu –Menu items –Check-box menu items –Separators –Menus

12 MenuItem( text ) --> ActionEvent CheckBoxMenuItem() --> ItemEvent menu.addSeparator() setHelpMenu() Menu

13 References All Material in this Presentation is heavily based on: Roberts, Simon and Heller, Philip, Java 1.1 Certification Study Guide, 1997: SYBEX™. ISBN: 0-7821-2069-5 Selected portions from JDK 1.1.6 JavaDoc HTML pages.


Download ppt "AWT Components (Chapter 9) Java Certification Study Group January 21, 1999 Mark Roth."

Similar presentations


Ads by Google