Hi, I am just begining to learn about applets and I have to draw a rectangle, but I am getting trouble even trying to draw the first line. Heres the error I get: "Applet1.java": Error #: 200 : ';' expected at line 12, column 17
public class Applet1 extends Applet { boolean isStandalone = false; public void paint(Graphics a) //this method displays the applet using the Graphics class to draw it. { void drawLine(int x0, int y0, int x1, int y1); } /**Get a parameter value*/ public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); }
which looks like the declaration of an interface method -- it's got a return type, and argument types... it's not a call to a method, which would be the only value way to use anything like this inside the paint() method (or any method).
drawLine() is a method of the Graphics class, and you have to supply numbers as arguments. You could replace that line with something like
a.drawLine(10, 10, 100, 100);
But in any case, it sounds like you're not just starting to learn about Applets, but actually just starting to learn about Java. You're going to need a book; you might try Head First Java as a gentle introduction.
Yes Iam supposed to use the line: void drawLine(int x0, int y0, int x1, int y1); As I am instructed to do in my Text book, but for some reason it doesn't work ? I maybe wrong so I'll try your advice and see if it works, Thanks! [ April 17, 2005: Message edited by: Michael Munro ]