首页 新闻 会员 周边

怎么将graphics添加到panel中啊

0
悬赏园豆:20 [已关闭问题] 关闭于 2013-10-26 09:48

public class SnakePlayPanel extends Panel{

public SnakePlayPanel(){
snakePlayPanel();
}
Panel playPanel=new Panel();//实例化了一个游戏panel面板的对象
public void snakePlayPanel(){
playPanel.setSize(450,447);
playPanel.setLocation(5,47);
playPanel.setBackground(Color.white);//设置背景色
}


public void paint(Graphics g) {
super.paint(g);
Color c=g.getColor();
g.setColor(Color.GRAY);
g.fillRect(0,0,450,447);
g.setColor(c);
}
}

 

为什么我的paint方法在panel中没有显示呢,我也确定我的panel已经添加到了frame中了啊,但是为什么这个paint方法在panel中不显示啊

追逐,小天的主页 追逐,小天 | 初学一级 | 园豆:197
提问于:2013-10-24 20:14
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册