|
|
Applet class to display a button
To create a button in an applet window that looks as
follows:
we can define an applet class (in a file called Button1.java):
//
Button1.java
// A program
that creates a button
// Kevin
Boone, May 1999
import
java.applet.Applet;
import
java.awt.*;
public class
Button1 extends Applet
{
public
Button1()
{
Button myButton = new Button ("Click
me");
add (myButton);
}
} // class
A
simple HTML file can be used to make the appletviewer run the applet:
<BODY>
<APPLET
CODE="Button1.class" height=100 width=200></APPLET>
</BODY>
Of
course, we have not coded any actions to respond to the event of a user
clicking on the button with their mouse - so if the button is clicked nothing
happens.
|
|