一个java的GUI小程序,编译时说main方法不对,请问哪里错了。。。
importjava.awt.*;publicclassTestPanel{publicstaticvoidmain(String[]args){newFrame1("T...
import java.awt.*;
public class TestPanel {
public static void main(String[] args) {
new Frame1("Test Panel",100,100,200,200,Color.BLUE,Color.RED);
}
class Frame1 extends Frame{
private Panel p;
Frame1(String s,int x,int y,int w,int h,Color c1,Color c2){
super(s);
setLayout(null);
p=new Panel(null);
this.setBackground(c1);
this.setBounds(x, y, w, h);
p.setBackground(c2);
p.setBounds(w/4, h/4, 2/w, 2/h);
add(p);
this.setVisible(true);
}
}
} 展开
public class TestPanel {
public static void main(String[] args) {
new Frame1("Test Panel",100,100,200,200,Color.BLUE,Color.RED);
}
class Frame1 extends Frame{
private Panel p;
Frame1(String s,int x,int y,int w,int h,Color c1,Color c2){
super(s);
setLayout(null);
p=new Panel(null);
this.setBackground(c1);
this.setBounds(x, y, w, h);
p.setBackground(c2);
p.setBounds(w/4, h/4, 2/w, 2/h);
add(p);
this.setVisible(true);
}
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询