为什么我的线程不能正确执行,请帮忙! paintComponent方法可能干别的去了,你不应该重写,应该重写方法paint 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 但是我在这个类里,把这句话 g2d.setColor(fxo);改成 g2d.setColor(color);就不能达到我要的效果,而用g2d.setColor(fxo)这条语句 就能正常运行,其中Color fxo是我在APPLET 中设定的变量,而color是这个内部类里的属性,为什么不行呢?而我在调用PainOval 的时候才调用构造函数的。jPanel1.add(new PaintOval(fxo),new XYConstraints(0,0,50,50));也就是我用g2d.setColor(color);这条语句时,我在监控线程中改变fxo的值,同时把他给new PaintOval(fxo),paintComponnent方法并没有去调用构造函数中被附值的color!这是为什么? class PaintOval extends JPanel { private Color color; public PaintOval(Color color) { super(); this.color = color; this.repaint(); } public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; super.paintComponent(g2d); //就是这里出问题 g2d.setColor(fxo); g2d.fillOval(7, 2, 20, 20); g2d.setColor(Color.black); g2d.drawOval(7, 2, 20, 20); this.repaint(); } } swing组件获得焦点的问题 急!跪求求4个JAVA简单问题 急问,请大家帮我,来着给分 如何用Runtime方法在JAVA中执行.BAT的文件 怎样计算程序运行的时间(在线等) volatile 关键字的意思是什么? 问一个简单的问题 求助:哪位大侠有rationalrose的crack文件,版本是RationalRoseEnterpriseEdition.2001.03.00.271.000 我该怎么办 浅谈java线程定时任务timerTask 为什么我的线程不能正确执行,请帮忙! 我的applet中的线程为什么不能正确运行,请大家来看看,帮帮我!
class PaintOval
extends JPanel {
private Color color;
public PaintOval(Color color) {
super();
this.color = color;
this.repaint();
} public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
super.paintComponent(g2d);
//就是这里出问题
g2d.setColor(fxo);
g2d.fillOval(7, 2, 20, 20); g2d.setColor(Color.black);
g2d.drawOval(7, 2, 20, 20);
this.repaint();
}
}