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

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

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

    俊星的BLOG

    SWT試用之控制鼠標鍵盤

    通過SWT可以控制鼠標鍵盤事件,具體如下:
    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;

    /**
     * 預期的運行效果為:顯示開始菜單
     * 
    @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(); // 鍵盤響應
            
    // new MouseThread(display).start(); // 鼠標響應
            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();
            
    // 移動鼠標
            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) {
            }

            
    // 恢復
            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) {
            }

            
    // 恢復
            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 俊星 閱讀(824) 評論(0)  編輯  收藏


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


    網站導航:
     
    主站蜘蛛池模板: 国产福利在线免费| 中文字幕永久免费| 中文文字幕文字幕亚洲色| 亚洲美女精品视频| 国产.亚洲.欧洲在线| 1000部国产成人免费视频| 免费观看a级毛片| 亚洲?V乱码久久精品蜜桃 | 99视频免费观看| 四虎国产精品免费久久| 亚洲男人的天堂久久精品| 美女被免费喷白浆视频| 三上悠亚亚洲一区高清| 亚洲中文字幕人成乱码| 国产特黄特色的大片观看免费视频| 国产免费爽爽视频在线观看| 免费看韩国黄a片在线观看| 亚洲日韩精品无码专区网址| 亚洲无人区码一二三码区别图片| a级成人毛片免费视频高清| 午夜免费福利在线| 国产亚洲美女精品久久| 老汉精品免费AV在线播放| 亚洲日韩乱码中文无码蜜桃 | www.黄色免费网站| 亚洲AV第一成肉网| 2015日韩永久免费视频播放| 黑人大战亚洲人精品一区| 国产成人综合亚洲一区| 国产亚洲大尺度无码无码专线| 久久99青青精品免费观看| 国产亚洲午夜高清国产拍精品| 久久精品国产这里是免费| 亚洲中文字幕伊人久久无码| 亚洲影院天堂中文av色| 亚洲午夜无码片在线观看影院猛| 日本免费大黄在线观看| 亚洲av成人一区二区三区观看在线| 亚洲中文字幕在线乱码| 免费观看的毛片大全| 国产成人无码免费网站|