e.doit:是否執行該事件API中的定義:boolean doitdepending on the event, a flag indicating whether the operation should be allowed.doit依賴於event(事件),是一個指示操作是否被允許的標誌。當doit值為true時為允許,反之則不被允許。在上面的代碼中,doit為true的時候,就被允許執行text.addKeyListener(new KeyListener()
當一個控制項被dispose後(即widget.isDispose返回為true時),調用該控制項的任何方法,都將報異常:org.eclipse.swt.SWTException: Widget is disposed當然,在記憶體中,控制項對應的對象仍然是存在的,並且只要它被引用,記憶體回收行程就不會去回收它。文檔說明: * Returns true if the widget has been disposed, * and false otherwise. * This method
VerifyEvent對象除了攜帶KeyEvent屬性外還有其他的一些屬性:◆ e.start 和 e.end:修改字元的起始位置。◆ e.text:新插入的文本。下面以一小程式來判斷使用者進行的操作是插入還是刪除: final Text text = new Text(shell, SWT.SINGLE); text.addVerifyListener(new VerifyListener(){ public void verifyText(VerifyEvent e) {
gc.setAlpha(int alpha) alpha的範圍為0-255alpha越小,越透明。alpha值越大,表示越不透明需要注意的是在使用這個特性時,需要設定gc.setAdvanced(true);方法原型為** * Sets the receiver's alpha value which must be * between 0 (transparent) and 255 (opaque). * <p> * This operation requires the
Control的幾個較重要的方法 1.control.toDisplay(x,y)方法原型:/**Returns a point which is the result of converting the argument, which is specified in coordinates relative tothe receiver, to display relative coordinates*/public Point toDisplay (int x, int y)
這裡把去點擊某個小組件(widget)所導致的事件的過程當作是被動的。因為事件觸發是被動的。主動是指在其它部分的代碼裡去觸發小組件所註冊的事件,而本身並沒有真正意義上的去點擊控制項。 使用樣本Event event = new Event();event.type = SWT.Selection;b1.notifyListeners(SWT.Selection, event); 方法描述和原型:/** * Notifies all of the receiver's listeners for