Hello everyone! I am trying to learn java and have run into kind of a
snag. Here is the code that I have so far:
------ <begin_code> ----------
import javax.swing.*;
import javax.swing.JApplet;
import javax.swing.JOptionPane;
import java.awt.Graphics;
public class Rectangles {
public static void main ( String args[] ) {
// Variables to hold the users input
String number1;
String number2;
String number3;
String number4;
int x;
int y;
int width;
int height;
nextRect: // Continue point for drawing another Rectangle
// Gather input and parse into integers
number1 = JOptionPane.showInputDialog(null, "Please input the x value: ");
number2 = JOptionPane.showInputDialog(null, "Please input the y value: ");
number3 = JOptionPane.showInputDialog(null, "Please input the width
value: ");
number4 = JOptionPane.showInputDialog(null, "Please input the height
value: ");
x = Integer.parseInt(number1);
y = Integer.parseInt(number2);
width = Integer.parseInt(number3);
height = Integer.parseInt(number4);
public void paint( Graphics g )
{
super.paint(g);
g.drawRect(x, y, width, height);
String answer;
answer = JOptionPane.showInputDialog(null, "Would you like to draw
another rectangle? ");
if ( answer == "yes | y")
continue nextRec; // go to nextRec and start over
else
System.exit(0);
}
}
}
------ </end_code> --------
Now, the problem I am having, is I am getting an error between the 't' and
the '(' in "public void paint( Graphics g )" Please be kind in your
comments and keep in mind that I am just learning. If I am trying to do
something that I shouldn't please let me know. I would really like to
know why this won't work.
Thank you in advance!
Regards,
jlk