I now have teo classes the first one contains this
import java.awt.*;
import javax.swing.*;
class fm1 extends JPanel
{
public fm1()
{
this.setLayout(new GridLayout(3,0));
Dimension D1 = new Dimension (300, 300);
JLabel fruit1 = new JLabel();
fruit1.setPreferredSize(D1);
fruit1.setOpaque(true);
this.add(fruit1);
JLabel fruit2 = new JLabel();
fruit2.setPreferredSize(D1);
fruit2.setOpaque(true);
this.add(fruit2);
JLabel fruit3 = new JLabel();
fruit3.setPreferredSize(D1);
fruit3.setOpaque(true);
this.add(fruit1);
}
}
This is the Standalone Class and it compiles fine
I then have this one
import java.awt.*;
import javax.swing.*;
class FruitWnd
{
public static void main(String[] args)
{
// Create and set up the JFrame
JFrame myWindow = new JFrame("Fruit Machine");
// Set the default close operation of the JFrame object to dispose
myWindow.setDefaultCloseOperation(3);
// Instance the standalone class containing the components
fm1 FruitMachine = new fm1();
// Add intermediate container to top level container
myWindow.add(FruitMachine,BorderLayout.CENTER);
// Display the window.
myWindow.pack();
myWindow.setVisible(true);
}// end of main method
}// end of class
When i Try to compile it it says that it cant find the fm1 class symbol. however on a very similar code it will compile it and i cant see the difference in order for me to solve it. can anyone help?