Java 如何使用GC重新绘制SWT表项,并重新绘制其他表项?
我有很多表项的SWT表,我正在使用paint Listener evnt.gc.drawText和event.gc.drawImage方法在表项中绘制细节Java 如何使用GC重新绘制SWT表项,并重新绘制其他表项?,java,user-interface,swt,paint,rcp,Java,User Interface,Swt,Paint,Rcp,我有很多表项的SWT表,我正在使用paint Listener evnt.gc.drawText和event.gc.drawImage方法在表项中绘制细节 调用table.redraw()方法时,整个表都会被重绘,但我只想重绘一个表项,而不影响其他表项获取要重绘和使用的项的表项: Rectangle bounds = tableItem.getBounds(); table.redraw(bounds.x, bounds.y, bounds.width, bounds.height, true
调用table.redraw()方法时,整个表都会被重绘,但我只想重绘一个表项,而不影响其他表项获取要重绘和使用的项的
表项
:
Rectangle bounds = tableItem.getBounds();
table.redraw(bounds.x, bounds.y, bounds.width, bounds.height, true);
要对图形对象使用PaintListener event.gc,首先需要使用table.setBounds(intx,inty,intwidth,intheight)选项设置表的边界。 如果对象未使用setBounds选项,则paintControl事件将不会对这些对象起作用
Canvas canvas = new Group(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
canvasSchema.setBounds(180, 5, 750, 500);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if(lstSchemaReq.getSelectionCount() > 0){
e.gc.drwaOval(100, 40, 50, 50);
}
}
});