1 / 13

AWT Components (Chapter 9)

AWT Components (Chapter 9). Java Certification Study Group January 21, 1999 Mark Roth. 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

Download Presentation

AWT Components (Chapter 9)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

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.

More Related