1 / 17

The AWT

The AWT. W. H. Carlisle. Java Abstract Window Toolkit. Supports development of user interfaces on widely different native window systems Depends on native system so widgets behave differently on different systems.

chaela
Download Presentation

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. The AWT W. H. Carlisle

  2. Java Abstract Window Toolkit Supports development of user interfaces on widely different native window systems Depends on native system so widgets behave differently on different systems. Is a “Lowest Common Denominator” toolkit - I.e. capabilities common to all platforms

  3. GUI programming is event driven. • 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.

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

  5. Goals reflect steps required to build a functioning GUI • Create the widget component • Add it to a container • Layout the component within the container • Handle the events generated by the widgets.

  6. Missing from the steps required • Setting resource values (color, font, etc.) of the widget. • “Lowest Common Denominator” widget design makes this difficult. • User defined components must subclass Canvas - I.e. must be drawn by windowing system.

  7. Component Widgets • Button - pushbutton, • 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

  8. Component Widgets Continued • List - a list of selectable items • Scrollbar - slider for scrolling • TextArea - a multi-line area for displaying and editing text • TextField -a single-line text area

  9. Slides showing appearance

  10. Components associated with menues • CheckboxMenuItem - toggle button in a menu • Menu - pulldown(or tear-off menu pane) • MenuBar - component to hold pulldown menues • MenuComponent - root of the menu component hierarchy • MenuItem - a menu button • PopupMenu - (1.1 only)

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

  12. On the Horizon Swing - a collection of new components in a package called the Java Foundation Classes (JFC) - see alligator appendix • 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

  13. Widgets are added to a Container Component -- after first deciding on a Layout Manager. • application GUIs needs at least one Frame. • Layout managers specify a policy for widget arrangement

  14. Layout Managers • implement the LayoutManager interface • 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. slide

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

  16. An Example: Greatest Integer

  17. Techniques to master: • 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. • Dialog box techniques to display a window from an event handler.

More Related