Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 need help with draw function
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mapleleafs




PostPosted: Tue Jul 27, 2004 2:17 pm   Post subject: need help with draw function

this applet is supposed to receive 4 inputs from the user for the x, y, width, and height of an oval and then it's supposed to draw the oval.

Here's the program
code:
// Draws an oval designed by user
import java.awt.Graphics;
import javax.swing.*;
public class DrawCircle extends JApplet {
        public void init()
        {
                String xInput,
                           yInput,
                           widthInput,
                           heightInput;
               
                int xValue,
                        yValue,
                        widthValue,
                        heightValue;
               
                xInput =
                        JOptionPane.showInputDialog(
                                "Enter x coordinate of oval" );
                yInput =
                        JOptionPane.showInputDialog(
                                "Enter y coordinate of oval" );
                widthInput =
                        JOptionPane.showInputDialog(
                                "Enter desired width of oval" );
                heightInput =
                        JOptionPane.showInputDialog(
                                "Enter desired height of oval" );
               
                xValue = Integer.parseInt( xInput );
                yValue = Integer.parseInt( yInput );
                widthValue = Integer.parseInt( widthInput );
                heightValue = Integer.parseInt( heightInput );
        } // end init()
       
        public void paint ( Graphics g )
        {
                g.drawOval( xValue, yValue,
                                                         widthValue, heightValue );
        } // end paint
} // end class DrawCircle


the problem is when i try to compile the program it says "cannot resolve symbol variable" for xValue, yValue, widthValue, and heightValue
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Tue Jul 27, 2004 4:43 pm   Post subject: (No subject)

its all because of scope.. u need to declare those variables outside the method init(). that way it is visible to all methods in that class
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: