AWT Components (Chapter 9) - PowerPoint PPT Presentation

liam
awt components chapter 9 l.
Skip this Video
Loading SlideShow in 5 Seconds..
AWT Components (Chapter 9) PowerPoint Presentation
Download Presentation
AWT Components (Chapter 9)

play fullscreen
1 / 13
Download Presentation
AWT Components (Chapter 9)
223 Views
Download Presentation

AWT Components (Chapter 9)

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

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

  2. 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

  3. 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 )

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

  5. 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

  6. 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 )

  7. 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

  8. 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)

  9. Constructing Container Components Applet() Frame( String title ) Panel() Dialog()

  10. 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

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

  12. 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.