本文整理匯總了Java中org.eclipse.swt.widgets.Canvas.addListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.addListener方法的具體用法?Java Canvas.addListener怎麽用?Java Canvas.addListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.Canvas
的用法示例。
在下文中一共展示了Canvas.addListener方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createPreviewArea
import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private void createPreviewArea(Composite cont) {
previewGrp = new Group(cont, SWT.NONE);
previewGrp.setText(Msgs.get("search.kws.preview"));
previewGrp.setLayout(new FillLayout());
// previewGrp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
canvas = new Canvas(previewGrp, SWT.NONE);
canvas.setBackground(Colors.getSystemColor(SWT.COLOR_GRAY));
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
if(currentImgOrig != null) {
Rectangle client = canvas.getClientArea();
if(currentImgScaled != null) {
currentImgScaled.dispose();
}
currentImgScaled = Images.resize(currentImgOrig, client.width, client.height,
Colors.getSystemColor(SWT.COLOR_GRAY));
Rectangle imgBounds = currentImgScaled.getBounds();
final int xOffset = (client.width - imgBounds.width) / 2;
e.gc.drawImage(currentImgScaled, xOffset, 0);
}
}
});
canvas.addListener (SWT.Resize, e -> {
if(currentImgOrig != null) {
canvas.redraw ();
}
});
}
示例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();
}
}
示例3: createTitleIcon
import org.eclipse.swt.widgets.Canvas; //導入方法依賴的package包/類
private Canvas createTitleIcon(final Composite parent, final Image icon) {
LOGGER.trace("Creating the title icon.");
final Canvas canvas = new Canvas(parent, SWT.NONE);
canvas.setBackground(parent.getBackground());
canvas.setBounds(icon.getBounds());
canvas.addListener(SWT.Paint, new Listener() {
@Override
public void handleEvent(Event event) {
event.gc.drawImage(icon, 0, 0);
}
});
return canvas;
}