Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,

Similar presentations


Presentation on theme: "CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,"— 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>

8 Sample Applet See SampleApplet.html


Download ppt "CS3157 Java UI Recitation. Material Covered: Overview of AWT components, Event Handling, creating applets, and sample UI. Not covered in recitation: Drawing,"

Similar presentations


Ads by Google