It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Using the drawoval method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using the drawoval method" Watch "Using the drawoval method" New topic
Author

Using the drawoval method

alsjo
Greenhorn

Joined: Feb 01, 2002
Posts: 4
I am writing a program where you enter in four int variables and than uses those to draw the oval. I'm having a problem passing the int variables into the drawoval method...Please HELP!
If you wish you may email me at:
joleneschmitcke@qwest.net
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
alsjo :
Can you post your code here? Have you tried to compile it ? What error do you get? At what line? Have you looked up the API for details on the drawOval method? How are you capturing the values that are to be the arguments to the drawOval method?
alsjo
Greenhorn

Joined: Feb 01, 2002
Posts: 4
public class OvalApplet extends JApplet
{
public void init()
{
String inleft;
String intop;
String inright;
String inbottom;
int x;
int y;
int right;
int bottom;

// Get input from user

// Convert numbers
x = Integer.parseInt( inleft );
y = Integer.parseInt( intop );
right = Integer.parseInt( inright );
bottom = Integer.parseInt( inbottom );

resize(300,300);
}
public void paint( Graphics g )
{
g.drawoval( x, y, right, bottom );
}
Getting the error for all variables:
java:50: cannot resolve symbol
symbol : variable bottom
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
Alsjo :
You are declaring the variables in one method ( init() ) and using them in another( Paint() ). Variables declared in one method are available only in that method.
Also how are you getting values in the
String variables that correspond to the X, Y etc?
I am getting the following errors as well for all the four string variables "Variable inbottom may not have been initialized."

Take a look at the example shapesdemo on sun's tutorial site :
http://java.sun.com/docs/books/tutorial/uiswing/painting/drawingShapes.html#eg1

Hope this helps
alsjo
Greenhorn

Joined: Feb 01, 2002
Posts: 4
Ok, I declared the variables globally now I'm getting the following error.
cannot resolve symbol
symbol : method drawoval (int,int,int,int)
location: class java.awt.Graphics
g.drawoval(x, y, right, bottom );
^
alsjo
Greenhorn

Joined: Feb 01, 2002
Posts: 4
HA...I got it...thanks for your help!!!
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
alsjo,
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please re-register under an appropriate name as shown in the policy. Your display name should have two names separated by a space and not obviously fictitious.
Thanks again and we hope to see you around the ranch!!


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
wood burning stoves
 
subject: Using the drawoval method