SWT JFace 002 事件4種不同寫法

2021-08-30 20:45:02 字數 4579 閱讀 1456

一、匿名內部類寫法

import org.eclipse.swt.swt;

import org.eclipse.swt.events.selectionadapter;

import org.eclipse.swt.events.selectionevent;

import org.eclipse.swt.graphics.point;

import org.eclipse.swt.layout.gridlayout;

import org.eclipse.swt.widgets.button;

import org.eclipse.swt.widgets.display;

import org.eclipse.swt.widgets.shell;

public class helloworld

});shell.open();

while (!shell.isdisposed())

display.dispose();

}}

import org.eclipse.swt.swt;

import org.eclipse.swt.events.selectionadapter;

import org.eclipse.swt.events.selectionevent;

import org.eclipse.swt.graphics.point;

import org.eclipse.swt.layout.gridlayout;

import org.eclipse.swt.widgets.button;

import org.eclipse.swt.widgets.display;

import org.eclipse.swt.widgets.shell;

public class helloworld

});} public static void main(string args)

display.dispose();

}}

二、命名內部類寫法

import org.eclipse.swt.swt;

import org.eclipse.swt.events.selectionadapter;

import org.eclipse.swt.events.selectionevent;

import org.eclipse.swt.graphics.point;

import org.eclipse.swt.layout.gridlayout;

import org.eclipse.swt.widgets.button;

import org.eclipse.swt.widgets.display;

import org.eclipse.swt.widgets.shell;

public class helloworld

display.dispose(); }

// 命名內部類實現事件

private static class buttonselectionlistener extends selectionadapter

}}

import org.eclipse.swt.swt;

import org.eclipse.swt.events.selectionadapter;

import org.eclipse.swt.events.selectionevent;

import org.eclipse.swt.graphics.point;

import org.eclipse.swt.layout.gridlayout;

import org.eclipse.swt.widgets.button;

import org.eclipse.swt.widgets.display;

import org.eclipse.swt.widgets.shell;

public class helloworld

// 命名內部類方式實現事件

private class buttonselectionlistener extends selectionadapter

} public static void main(string args)

display.dispose();

}}

三、外部類寫法

import org.eclipse.swt.swt;

import org.eclipse.swt.events.selectionadapter;

import org.eclipse.swt.events.selectionevent;

import org.eclipse.swt.graphics.point;

import org.eclipse.swt.layout.gridlayout;

import org.eclipse.swt.widgets.button;

import org.eclipse.swt.widgets.display;

import org.eclipse.swt.widgets.shell;

public class helloworld

display.dispose(); }}

// 外部類實現事件

class buttonselectionlistener extends selectionadapter

}

import org.eclipse.swt.swt;

import org.eclipse.swt.events.selectionadapter;

import org.eclipse.swt.events.selectionevent;

import org.eclipse.swt.graphics.point;

import org.eclipse.swt.layout.gridlayout;

import org.eclipse.swt.widgets.button;

import org.eclipse.swt.widgets.display;

import org.eclipse.swt.widgets.shell;

public class helloworld

public static void main(string args)

display.dispose(); }}

//外部類實現事件

class buttonselectionlistener extends selectionadapter

}

四、實現監聽介面的寫法

import org.eclipse.swt.swt;

import org.eclipse.swt.events.selectionadapter;

import org.eclipse.swt.events.selectionevent;

import org.eclipse.swt.graphics.point;

import org.eclipse.swt.layout.gridlayout;

import org.eclipse.swt.widgets.button;

import org.eclipse.swt.widgets.display;

import org.eclipse.swt.widgets.shell;

public class helloworld extends selectionadapter

display.dispose(); }

@override

public void widgetselected(selectionevent e)

}

import org.eclipse.swt.swt;

import org.eclipse.swt.events.selectionadapter;

import org.eclipse.swt.events.selectionevent;

import org.eclipse.swt.graphics.point;

import org.eclipse.swt.layout.gridlayout;

import org.eclipse.swt.widgets.button;

import org.eclipse.swt.widgets.display;

import org.eclipse.swt.widgets.shell;

public class helloworld extends selectionadapter

@override

public void widgetselected(selectionevent e)

public static void main(string args)

display.dispose();

}}

《eclipse從入門到精通》 陳剛 著  讀書筆記

貪吃蛇002(增加退出遊戲事件)

視窗變數 windows width 800 windows height 480 cell size 20 方塊大小 map width windows width cell size map hight windows height cell size 設定顏色變數 white 255,255,...

UE4 事件委託

1 先在標頭檔案上面宣告乙個 名字要以f開頭 宣告乙個事件委託 第乙個引數事件的名稱 自己定義 後面的引數是事件所需要的引數 因為有6個引數 所以新增 sixparams declare dynamic multicast delegate sixparams fonhealthchangesign...

五 效能監視(4)擴充套件事件

一 擴充套件事件 extended events,簡稱xe sql server 2008提供了一種新的方法,用來診斷故障和捕獲內部資訊。與其它跟蹤技術相比,擴充套件事件的優勢在於 1.擴充套件事件位於sql server的總體層中,因此它能與各級sql server主機進行互動。2.擴充套件事件是...