-
Help me!!!
I am trying to create an applet to look like the following, but I am stumped. I am new to this and not sure where to turn.
Number Square Cube
0 0 0
1 1 1
2 4 8
This is what I have and all I get is errors:
Code:
// java packages
import java.awt.Graphics;
import javax.swing.JApplet;
public class A3_3 extends JApplet {
double one = 1;
public void init()
{
public void paint( Graphics g )
{
super.paint( g );
g.drawString( "Number","Square","Cube", 0, 25 );
g.drawString(one, one * one, one * one* one, 0, 25 );
System.exit( 0 );
}
}
[Archangel added CODE tags]
-
Use JLabels - they're easier.
-
Errors
What errors? With the drawString? Unless I'm mistaken, drawString should just take one text argument, so why not try:
g.drawString( "Number, Square, Cube", 0, 25 );
g.drawString(one+" "+one * one+" "+one * one * one, 0, 25 );
You'll really need a loop to do three lines, incrementing the y positon to draw each time.
Ralpharama.