Results 1 to 3 of 3
Thread: Cannot find symbol
- 09-16-2012, 01:59 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
Cannot find symbol
I am a newbie to swings..please help me out in solving this..
I need to change the colors of circle each time the button is being clicked
I have two classes namely Gui4.java and MyDrawPanel.java ..I am trying to create an object for MyDrawPanel in Gui4 and use the getContentpane() method.I am posting t codes of both program.I am executing thro cmd prompt.
//Gui4.java
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Gui4 implements ActionListener
{
JFrame frame;
public static void main(String[] args)
{
Gui4 gui = new Gui4();
gui.go();
}
public void go()
{
frame = new JFrame (" change colors");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
JButton button = new JButton();
button.addActionListener(this);
MyDrawPanel drawpanel = new MyDrawpanel();
frame.getContentPane().add(BorderLayout.SOUTH,butt on);
frame.getContentPane().add(BorderLayout.CENTER,dra wpanel);
frame.setSize(300,300);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event)
{
frame.repaint();
}
}
//MyDrawPanel.java
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class MyDrawPanel extends JPanel
{
public void paintComponent(Graphics g)
{
g.fillRect(0,0,this.getWidth(),this.getHeight());
int red = (int) (Math.random()*255);
int green = (int) (Math.random()*255);
int blue = (int) (Math.random()*255);
Color random = new Color(red,green,blue);
g.setColor(random);
g.fillOval(70,70,100,100);
}
}
And I am getting the error as follows :
D:\jp>javac Gui4.java
Gui4.java:21: error: cannot find symbol
MyDrawPanel drawpanel = new MyDrawpanel();
^
symbol: class MyDrawpanel
location: class Gui4
1 error
Please help me out in getting output.
Thanks,
sam
- 09-16-2012, 02:03 PM #2
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
Re: Cannot find symbol
sorry to all...I found the mistake..
I have used small letter while creating the object...
Plez forgive my mistake...
Thanks again ,
Sam
- 09-16-2012, 02:27 PM #3
Re: Cannot find symbol
If you're forever cleaning cobwebs, it's time to get rid of the spiders.
Similar Threads
-
Cannot Find Symbol
By Concacaf in forum New To JavaReplies: 5Last Post: 05-09-2011, 01:47 PM -
Cannot find symbol
By Johanis in forum New To JavaReplies: 18Last Post: 11-09-2010, 09:34 PM -
Still cannot find symbol!
By Johanis in forum New To JavaReplies: 1Last Post: 11-04-2010, 05:32 PM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 09:26 PM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 09:30 AM
Bookmarks