Java中(Graphics g)绘图方面的知识,求助
publicclassTestextendsJFrame{gamePanelgamep=null;publicstaticvoidmain(String[]args){T...
public class Test extends JFrame{
gamePanel gamep=null;
public static void main(String[] args){
Test demo2_4=new Test();
}
public Test(){
gamep=new gamePanel();
this.add(gamep);
//设置窗体属性
this.setSize(500,500);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
}
//定义panel //继承接口KEYListener
class gamePanel extends JPanel{
public void paint(Graphics g){
super.paint(g);
setSize(480,460);
System.out.print("方向");
g.drawOval(10, 10, 20, 20);
System.out.println("次数");
}
}
为什么 g.drawOval(10, 10, 20, 20);这句话被执行了3次?求助 展开
gamePanel gamep=null;
public static void main(String[] args){
Test demo2_4=new Test();
}
public Test(){
gamep=new gamePanel();
this.add(gamep);
//设置窗体属性
this.setSize(500,500);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
}
//定义panel //继承接口KEYListener
class gamePanel extends JPanel{
public void paint(Graphics g){
super.paint(g);
setSize(480,460);
System.out.print("方向");
g.drawOval(10, 10, 20, 20);
System.out.println("次数");
}
}
为什么 g.drawOval(10, 10, 20, 20);这句话被执行了3次?求助 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询