•
•
•
•
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
![]() |
•
•
Join Date: Jul 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
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
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
•
•
Join Date: Jul 2005
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
•
•
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation:
Rep Power: 9
Solved Threads: 18
You have an older version that's why.
try this;
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();
}![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
- Cannot Resolve Symbol (Java)
- cannot resolve symbol symbol : variable JoptionPane (Software Developers' Lounge)
- Still cannot resolve symbol (Java)
- Cannot resolve symbol (Java)
- Cannot resolve symbol (Java)
- "cannot resolve symbol"problem (Java)
- Cannot resolve symbol message appears when compiling (Java)
Other Threads in the Java Forum
- Previous Thread: help for project needed
- Next Thread: scrollbar applet



Linear Mode