1 / 8

CS3157 Java UI Recitation

CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing, Images, Layout Manager. AWT Components. Containers: Windows (Frame, Dialog, FileDialog) , Panel, Scroll Pane

Download Presentation

CS3157 Java UI Recitation

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. CS3157 Java UI Recitation

  2. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. • Not covered in recitation: Drawing, Images, Layout Manager

  3. AWT Components • Containers: Windows (Frame, Dialog, FileDialog) , Panel, Scroll Pane • Basic Controls: Buttons, Checkbox, Choice, List, MenuItem, TextField • Others Components: Slider, ScrollBar, TextArea, Label, Canvas

  4. Component Hierarchy • All components except for menu related components inherit from the AWT Component class.

  5. Windows, Frames and Dialogs are top level containers. • Add components to another component. • i.e. Add a panel to a frame • Add a button to a panel • Add event listeners to component

  6. Event Handling • 1.1 AWT Event Modeling • Event generated by event sources. • Listeners register to be notified about events • Event handler implements event listener interface • public class MyEventHandler implements ActionListener { } • Register listener on a component • myComponent.addActionListener(myEventHandler); • Implementation of methods in the listener interface • public void actionPerformed(ActionEvent e) { // code that reacts to the action }

  7. Applet • extends java.applet.Applet class • Methods: • init() // initialize applet • start() // start applet • stop() // stop applet • destroy() // cleanup, unload applet • Running an applet • Embed applet in an html <APPLET CODE=AppletSubclass.class WIDTH=anInt HEIGHT=anInt> </APPLET>

  8. Sample Applet • See SampleApplet.html

More Related