本文整理匯總了Java中org.eclipse.swt.widgets.Canvas.addDisposeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.addDisposeListener方法的具體用法?Java Canvas.addDisposeListener怎麽用?Java Canvas.addDisposeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.Canvas
的用法示例。
在下文中一共展示了Canvas.addDisposeListener方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSWTControl
import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
@Override
protected Canvas createSWTControl(final Composite parent) throws Exception
{
createColors();
// Unfortunately, the canvas is not transparent..
final Canvas canvas = new Canvas(parent, SWT.NO_FOCUS | SWT.NO_BACKGROUND | SWT.TRANSPARENT);
canvas.addPaintListener(this::doPaint);
canvas.addDisposeListener((e) ->
{
for (final Color color : colors)
color.dispose();
});
return canvas;
}
示例2: adjustItemNumber
import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
protected void adjustItemNumber() {
if (fComposite == null)
return;
Control[] children= fComposite.getChildren();
int oldSize= children.length;
int newSize= fInput == null ? 0 : fInput.fAnnotations.length;
Display display= fShell.getDisplay();
// add missing items
for (int i= oldSize; i < newSize; i++) {
Canvas canvas= new Canvas(fComposite, SWT.NONE);
Object gridData= fLayouter.getLayoutData();
canvas.setLayoutData(gridData);
canvas.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
canvas.addPaintListener(fPaintListener);
canvas.addMouseTrackListener(fMouseTrackListener);
canvas.addMouseListener(fMouseListener);
canvas.addListener(SWT.MenuDetect, fMenuDetectListener);
canvas.addDisposeListener(fDisposeListener);
}
// dispose of exceeding resources
for (int i= oldSize; i > newSize; i--) {
Item item= (Item) children[i - 1].getData();
item.deselect();
children[i - 1].dispose();
}
}