File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using the drawoval method

 
alsjo
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 203
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 203
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HA...I got it...thanks for your help!!!
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic