User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 397,772 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,540 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 3694 | Replies: 3
Reply
Join Date: Jul 2005
Posts: 3
Reputation: yarlini is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
yarlini yarlini is offline Offline
Newbie Poster

"Cannot Resolve Symbol"

  #1  
Jul 12th, 2005
HI
ive been trying to do some java program and when ive tried to run this program which, ive had 3 errors saying cannot resolve symbol for 'DrawFrame/DrawPanel' im not sure wat the issue here is, the program is as follows:

import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;

public class Drawing extends DrawPanel
{
public static void main(final String[] args)
{
DrawFrame frame = new DrawFrame("Drawing");

Drawing drawing = new Drawing();

frame.add(drawing);
frame.pack();
frame.centreOnScreen();
frame.setVisible(true);
}

public Drawing()
{
}
public Drawing(final int w, final int h)
{
super(w,h);
}

public void paint(final Graphics g)
{
Graphics2D g2d = (Graphics2D)g;
}
}


it would be much appreciated if you could help
thnx
yarlini
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: india
Posts: 44
Reputation: cheenu78 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
cheenu78's Avatar
cheenu78 cheenu78 is offline Offline
Light Poster

Re: "Cannot Resolve Symbol"

  #2  
Jul 12th, 2005
hi yarlini

your problem lies on the following lines:

DrawFrame frame = new DrawFrame("Drawing");

and

public class Drawing extends DrawPanel

bcos these clases are neither in swing nor classes that you created.
So the compiler says it is not able to recognize the classes

I think this is what you are looking at:
[HTML]
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;

class Drawing extends JPanel
{
Drawing()
{
setBackground(Color.cyan);
setPreferredSize(new Dimension(50,50));
}
}

class Main
{
public static void main(final String[] args)
{
JFrame frame = new JFrame("Drawing");
frame.setLayout(new FlowLayout());
frame.setSize(300,300);
Drawing drawing = new Drawing();
Drawing drawing1 = new Drawing();

frame.add(drawing);
frame.add(drawing1);

frame.setVisible(true);
frame.repaint();
}
}
[/HTML]
I have modified you code a bit,

compile the program as
javac Main.java

run the program as
java Main
Reply With Quote  
Join Date: Jul 2005
Posts: 3
Reputation: yarlini is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
yarlini yarlini is offline Offline
Newbie Poster

Help Re: "Cannot Resolve Symbol"

  #3  
Jul 12th, 2005
thnx for the code when i compiled and ran the program i received an error:

"Exception in thread 'main' java.lang.Error: Do not use javax.swing.JFrame.SetLayout() use javax.swing.JFrame.getContentPane().setLayout() instead at javax.swing.JFrame.createRootPaneException(Unknown Source) at Javax.swing.JFrame.setLayout(Unknown Source) at Main.main(Main.java:19)

and this kept running and didnt terminate
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: "Cannot Resolve Symbol"

  #4  
Jul 12th, 2005
You have an older version that's why.

try this;
	public static void main(final String[] args)
	{
	JFrame frame = new JFrame("Drawing");
	frame.getContentPane().setLayout(new FlowLayout());
	frame.setSize(300,300);
	Drawing drawing = new Drawing();
	Drawing drawing1 = new Drawing();

	frame.getContentPane().add(drawing);
	frame..getContentPane().add(drawing1);

	frame.setVisible(true);
	frame.repaint();
	}
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 4:33 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC