<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    俊星的BLOG

    SWT試用之控制鼠標(biāo)鍵盤

    通過SWT可以控制鼠標(biāo)鍵盤事件,具體如下:
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Event;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;

    /**
     * 預(yù)期的運(yùn)行效果為:顯示開始菜單
     * 
    @author kinkding
     * @history 2009-6-2
     
    */

    public class MyEventRes {

        
    public static void main(String[] args) {
            
    final Display display = new Display();
            
    final Shell shell = new Shell(display);
            
    final Text text = new Text(shell, SWT.BORDER);
            text.setSize(text.computeSize(
    150, SWT.DEFAULT));
            text.setText(
    "神一樣的人啊!");
            shell.pack();
            shell.open();

            
    new KeyThread(display).start(); // 鍵盤響應(yīng)
            
    // new MouseThread(display).start(); // 鼠標(biāo)響應(yīng)
            while (!shell.isDisposed()) {
                
    if (!display.readAndDispatch())
                    display.sleep();
            }

            display.dispose();
        }

    }


    class MouseThread extends Thread {
        Display display;
        
    int h;

        
    public MouseThread(Display display) {
            
    this.display = display;
            h 
    = display.getPrimaryMonitor().getBounds().height;
        }


        
    public void run() {
            Event event 
    = new Event();
            
    // 移動鼠標(biāo)
            event.type = SWT.MouseMove;
            event.x 
    = 5;
            event.y 
    = h - 5;
            display.post(event);
            
    try {
                Thread.sleep(
    100);
            }
     catch (InterruptedException e) {
            }

            
    // 按下右鍵
            event.type = SWT.MouseDown;
            event.button 
    = 1;
            display.post(event);
            
    try {
                Thread.sleep(
    100);
            }
     catch (InterruptedException e) {
            }

            
    // 恢復(fù)
            event.type = SWT.MouseUp;
            display.post(event);
        }

    }


    class KeyThread extends Thread {
        Display display;
        
    int h;

        
    public KeyThread(Display display) {
            
    this.display = display;
            h 
    = display.getPrimaryMonitor().getBounds().height;
        }


        
    public void run() {
            Event event 
    = new Event();
            
    // 按下CTRL
            event.type = SWT.KeyDown;
            event.keyCode 
    = SWT.CTRL;
            display.post(event);
            
    try {
                Thread.sleep(
    100);
            }
     catch (InterruptedException e) {
            }

            
    // 按下ESC
            event.type = SWT.KeyDown;
            event.keyCode 
    = SWT.ESC;
            display.post(event);
            
    try {
                Thread.sleep(
    100);
            }
     catch (InterruptedException e) {
            }

            
    // 恢復(fù)
            event.type = SWT.KeyUp;
            event.keyCode 
    = SWT.CTRL;
            display.post(event);
            
    try {
                Thread.sleep(
    100);
            }
     catch (InterruptedException e) {
            }

            event.type 
    = SWT.KeyUp;
            event.keyCode 
    = SWT.ESC;
            display.post(event);
        }

    }

    posted on 2009-06-02 00:15 俊星 閱讀(820) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲视频一区二区在线观看| 香蕉视频免费在线播放| 久久久久亚洲精品无码网址色欲| 中文字幕不卡免费视频| 成人免费无码大片a毛片| 在线亚洲97se亚洲综合在线| 国产成人亚洲综合一区| 无码少妇精品一区二区免费动态| 亚洲成AV人在线观看网址| 亚洲人精品亚洲人成在线| 九月婷婷亚洲综合在线| 午夜亚洲国产理论片二级港台二级| 亚洲一区二区高清| yellow视频免费看| 一本久久综合亚洲鲁鲁五月天 | 一级午夜a毛片免费视频| 久久青青草原亚洲av无码app| 最新国产乱人伦偷精品免费网站| 亚洲AV无码一区二三区| 最近中文字幕电影大全免费版 | 99精品视频在线观看免费| 亚洲日韩av无码| 91福利免费网站在线观看| 亚洲色无码国产精品网站可下载| 最近的中文字幕大全免费版| a视频在线观看免费| 国产亚洲精彩视频| 亚洲伊人久久成综合人影院| 91在线品视觉盛宴免费| 亚洲1234区乱码| 99在线视频免费观看视频| 日韩a级无码免费视频| 国产亚洲欧美在线观看| 免费一级一片一毛片| 日本一区二区三区在线视频观看免费 | 国产精品免费大片| 亚洲首页在线观看| 亚洲日韩aⅴ在线视频| 日韩亚洲精品福利| 精品久久久久久久免费人妻| 羞羞视频免费网站入口|