當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.addListener方法代碼示例

本文整理匯總了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 ();
	    	}
		});
	}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:31,代碼來源:KwsResultViewer.java

示例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();
	}

}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:37,代碼來源:AnnotationExpansionControl.java

示例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;
}
 
開發者ID:Haixing-Hu,項目名稱:swt-widgets,代碼行數:14,代碼來源:BalloonWindow.java


注:本文中的org.eclipse.swt.widgets.Canvas.addListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。