1 / 11

GUI in JAVA - The AWT

Chapter 8. GUI in JAVA - The AWT. Goals AWT Components Layout Managers Frame Example Applet Example. Goals. First learn about the different objects that you can put on the screen Second address their associated events and provide event handling

marius
Download Presentation

GUI in JAVA - The AWT

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. Chapter 8 GUI in JAVA - The AWT • Goals • AWT Components • Layout Managers • Frame Example • Applet Example

  2. Goals • First learn about the different objects that you can put on the screen • Second address their associated events and provide event handling • Almost all visual components are ultimately residing in a frame or panel • Frame - for application; Panel - for applet.

  3. Goals • Understand event handling for AWT components • Understand the widgets available in Java • Understand how widgets must be attached to containers • Understand how “layout managers” support positioning

  4. AWT - Abstract Windowing Toolkit • AWT can be used by both, applets and self-standing applications. • Is a standard component of the Java Development Kit (JDK) • Support for • mouse • keyboard • event handling

  5. AWT Components • Button - pushbutton, • Label • Canvas - blank for drawing • Checkbox - togglebutton • Choice - Drop-down list, option menu • Component - root of the hierarchy (can be subclassed in 1.1) • FileDialog - supports browsing and selecting files • List - a list of selectable items

  6. More Components • Scrollbar - slider for scrolling • TextArea - a multi-line area for displaying and editing text • TextField -a single-line text area • CheckboxMenuItem - toggle button in a menu • Menu - pulldown(or tear-off menu) • MenuBar - component to hold pulldown menues • MenuComponent - root of the menu component hierarchy • MenuItem - a menu button • PopupMenu - (1.1 only)

  7. Container Components • Container - root of hierarchy (abstract - not displayable) • Dialog - suitable for dialog boxes • Frame - top-level window that can contain a menubar • Panel - empty toplevel container (parent of applet) • ScrollPane (1.1container that scrolls contents) • Window - no border. no menubar- parent of Frame and Dialog.

  8. Layout Managers • Layout managers specify a policy for widget arrangement • BorderLayout - max of 5 components • NORTH,SOUTH,EAST,WEST,CENTER • default layout for Windows and its subclasses Frame and Dialog • FlowLayout - components are placed centered and left to right in a row • new row started when previous row is full • default layout for Panels and subclass Applet.

  9. More Layout Managers • GridLayout - an n by m grid of components placed left to right, top to bottom. • GridBagLayout - components can take up adjacent grid positions through use of a GridBagConstraints object. • CardLayout - only one component is seen at a time with the ability to pull a component into view.

  10. Application vs Applet • An applet is a subclass of panel. Thus it has a display area in which to draw graphics or display. • An application must create its own window done with a Frame object. • Application programming should register the Frame with a WindowListener to handle a closing event. • Only frames may contain menubars, but in 1.1 popup menues are not restricted to frames.

  11. Swing • a collection of new components in a package called the Java Foundation Classes (JFC) • Support “tool tips” as pop-up labels that describe purpose of a component • Provide new high demand widgets such as • “tabbed panes” as sub panes each with a folder type tab • trees to display nested directory structures with a ‘+ ‘ to expand the tree • tables to display information returned from database access

More Related