Presentation is loading. Please wait.

Presentation is loading. Please wait.

Applets Yong Choi School of Business CSU, Bakersfield.

Similar presentations


Presentation on theme: "Applets Yong Choi School of Business CSU, Bakersfield."— Presentation transcript:

1 Applets Yong Choi School of Business CSU, Bakersfield

2 What’s an Applet? Applets- Programs that are called from within another application You run applets on the Internet, an intranet, and an extranet a local computer from within another program called Applet Viewer To view an applet, it should be called from within another document written in HTML Visit Java API to see the applet package

3 Execution of an Applet Applets are popular because users can execute them using a Web browser Web browser: A program that allows you to display HTML documents on your computer screen Internet Explorer Netscape Navigator

4 Understanding Simple Applets To write an applet you must also: Include import statements to ensure that necessary classes are available Learn to use some Windows components and applet methods Learn to use the keyword extends

5 Writing an HTML Document to Host an Applet Code to run an applet from within an HTML document (use the clip library of TextPad) Need only two tags: but usually, programmers need to place three attributes within the tag For example

6 Attributes of an Applet Applet tag attributes CODE = is followed by the name of the compiled applet you are calling WIDTH = is followed by the width of the applet on the screen HEIGHT = is followed by the height of the applet on the screen The WIDTH and HEIGHT attributes are measured in pixels Pixels: Picture elements, or tiny dots that make up the image on your video monitor

7 Refer to the Java API for detail information

8 Using Labels with Simple AWT Applets The java.awt package contains commonly used Windows components such as: Labels Menus Buttons Label: Built-in class that holds text that you can display within an applet

9 Understanding Component and Container Component- A class that defines any object that you want to display Such as GUI component - Frames, panels, buttons, labels, and text fields Container- A class that is used to define a component that can contain other components Your browser is a container that contains buttons, labels, text fields…..

10 Understanding AWT Most AWT applets contain 2 import statements import java.applet.*; import java.awt.*; java.applet- Contains a class named Applet Every applet you create is based on Applet java.awt- The Abstract Windows Toolkit, or AWT Used to be a package for GUI in Java 1.1

11 Understanding Simple Applets Most Swing applets contain 2 import statements import javax.swing.*; import java.awt.*; javax.swing- A package that contains classes that define GUI components (refer to as Swing components)

12 Complete Applet and GUI Part 5: Applets and Graphics Part 8: Graphical User Interface Programming


Download ppt "Applets Yong Choi School of Business CSU, Bakersfield."

Similar presentations


Ads by Google