要停止Alt-F4:
yourframe.setDefaultCloseOperation(Jframe.DO_NOTHING_ON_CLOSE);
要停止Alt-Tab,您可以做一些更具侵略性的事情。
public class AltTabStopper implements Runnable{ private boolean working = true; private Jframe frame; public AltTabStopper(Jframe frame) { this.frame = frame; } public void stop() { working = false; } public static AltTabStopper create(Jframe frame) { AltTabStopper stopper = new AltTabStopper(frame); new Thread(stopper, "Alt-Tab Stopper").start(); return stopper; } public void run() { try { Robot robot = new Robot(); while (working) { robot.keyRelease(KeyEvent.VK_ALT); robot.keyRelease(KeyEvent.VK_TAB); frame.requestFocus(); try { Thread.sleep(10); } catch(Exception) {} } } catch (Exception e) { e.printStackTrace(); System.exit(-1); } }}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)