Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用GC重新绘制SWT表项,并重新绘制其他表项?_Java_User Interface_Swt_Paint_Rcp - Fatal编程技术网

Java 如何使用GC重新绘制SWT表项,并重新绘制其他表项?

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

我有很多表项的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);

要对图形对象使用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);
  }
 }
});