【发布时间】:2010-12-26 02:46:27
【问题描述】:
如何使用paint(),这样当调用repaint() 时,先前绘制的对象在绘制新对象时不应该被删除。那就是绘图区域必须只更新而不是重绘。
在我的代码中,当单击多个按钮之一时,会显示一些 aplhabet。我希望具有这样的功能,即当单击其他按钮时,必须存在先前绘制的字母。就像单击按钮时创建的一串字母一样。 我使用 Java Swing 进行编码。
我的一些代码:
if(source == btnAlpha[i] )
bollyDraw.repaint(); //bollydraw is an object of a JPanel extended class having implemented the paintComponent(Graphics g) method
在paint()方法中:
if (word[i] == key) {
g.drawChars(word, i, 1, x, y);
}
【问题讨论】: