【发布时间】:2015-08-17 15:39:58
【问题描述】:
这是我的代码。我对编码有点陌生,所以请多多解释。
public class main extends JPanel{
public static Window f = new Window();
public static int Width = 600;
public static int Hight = 400;
public static void main(String args[]){
f.setSize(Width, Hight);
f.setVisible(true);
f.setResizable(false);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setTitle("FightForYourLife");
f.setLocationRelativeTo(null);
}
public void main(){
JPanel panel = this;
}
public void paintComponent(Graphics g){
super.paintComponent(g);
g.setColor(Color.RED);
g.fillRect(100, 100, 50, 30);
System.out.println("IT IS PAINTING");
}
}
【问题讨论】:
标签: java swing paintcomponent