⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 standbydetector.java

📁 WinTVCap_GUI-3.3.6-src.zip,WINCE下的源码,JAVA开发
💻 JAVA
字号:
package com.ha.common.windows;

/**
 * This class is used to detect is standby(sleep) was requested on the PC it is running on
 * and to disallow it optionally
 * 
 * From: http://www.codeguru.com/cpp/w-p/system/messagehandling/article.php/c6907/
 */
public class StandByDetector {
    static {
        System.loadLibrary("StandByDetector");
    }
    private StandByRequestListener listener;
    
    public StandByDetector(StandByRequestListener listener) {
        this.listener = listener;
        init();
    }
    
    public void fireStandByRequested() {
        listener.standByRequested();
    }
    
    private native boolean init();
  /*
     allowStandBy==false
     means that no standby is allowed while this app is running
   */
    public native void setAllowStandby(boolean allowStandby);
    public native void destroy();
    
    //for testing...
    public static void main(String args[]) {
        StandByDetector sd=new StandByDetector(new StandByRequestListener() {
            public void standByRequested() {
                System.out.println("standby requested");
            }
        });
        sd.setAllowStandby(false);
        javax.swing.JFrame f=new javax.swing.JFrame();
        f.getContentPane().add(new javax.swing.JLabel("close to end test"));
        f.setSize(300,100);
        f.setVisible(true);
        f.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -