Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The public type fzwFrames must be defined in its own file.谢谢大家!
=========================================================================================================
program:
import java.awt.*;
import java.io.*;public class Centerpanel {
public static void main(String[] args)
{fzwFrames f=new fzwFrames (300,300,400,300,Color.BLUE);
}
}
public class fzwFrames extends Frame
{
public Panel p; fzwFrames(int x,int y,int w,int h,Color c)
{super("FramewithPanel");
setLayout(null);
setBounds(x,y,w,h);
setBackground(c);
p= new Panel(null);
p.setBounds(w/2, h/4, w/2, h/2);
p.setBackground(Color.yellow);
add(p);
setVisible(true);
}}
The public type fzwFrames must be defined in its own file.谢谢大家!
=========================================================================================================
program:
import java.awt.*;
import java.io.*;public class Centerpanel {
public static void main(String[] args)
{fzwFrames f=new fzwFrames (300,300,400,300,Color.BLUE);
}
}
public class fzwFrames extends Frame
{
public Panel p; fzwFrames(int x,int y,int w,int h,Color c)
{super("FramewithPanel");
setLayout(null);
setBounds(x,y,w,h);
setBackground(c);
p= new Panel(null);
p.setBounds(w/2, h/4, w/2, h/2);
p.setBackground(Color.yellow);
add(p);
setVisible(true);
}}
并且,class的名字和文件名要相同。这是Java的基础中的基础了,随便拿本Java的书上都有讲的应该。