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

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:

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();
	}
}

I have modified you code a bit,

compile the program as
javac Main.java

run the program as
java Main

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

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();
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.