To make a GUI (graphical user interface, in case you were wondering) in JAVA, you need to make an import statement that brings in the Java "awt" library. "Awt" stands for "abstract windowing toolkit", and it contains all the stuff you need in order to make Java programs that look like, well, like programs.
so here's the first step, adding the two import statements for this program:
import java.awt.*;
import java.applet.Applet;
next, lets name our public class just below those two imports, then add the curly braces:
public class OneButton extends Applet
{
}// end class
next, get in between those curly braces, and add an init method. You need to use an init method in a JAVA applet to setup stuff that the rest of the program will use. Yours will add a button to your GUI:
public void init( )
{
Button b = new Button("OK");
add(b);
}
OK, now you need to save the program -- remember, just copy the class name and use that for the file name. Then, compile it, and run it -- remember, it's an applet, so use Ctrl + 3
cheers,
Uncle Paulie

No comments:
Post a Comment