首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

关于JPanel的有关问题

2012-01-01 
关于JPanel的问题?我在JPanel上用drawLine函数绘制了一系列线条,现在我想清除这些线条,请问怎么清除啊?[解

关于JPanel的问题?
我在JPanel上用drawLine函数绘制了一系列线条,现在我想清除这些线条,请问怎么清除啊?

[解决办法]
用背景色再画一条线上去
[解决办法]
clearRect()可以清除全部的东东.
[解决办法]
clearRect
public abstract void clearRect(int x,
int y,
int width,
int height)
Clears the specified rectangle by filling it with the background color of the current drawing surface. This operation does not use the current paint mode.
Beginning with Java 1.1, the background color of offscreen images may be system dependent. Applications should use setColor followed by fillRect to ensure that an offscreen image is cleared to a specific color.


Parameters:
x - the x coordinate of the rectangle to clear.
y - the y coordinate of the rectangle to clear.
width - the width of the rectangle to clear.
height - the height of the rectangle to clear.


for example:
g.clearRect(0, 0, 400, 400);

热点排行