| 46 | import javax.swing.text.Keymap; |
| 47 | |
| 48 | @SuppressWarnings("unused") |
| 49 | public class Test_Event extends JFrame { |
| 50 | |
| 51 | static boolean logging = true; |
| 52 | |
| 53 | boolean asInternalFrame = false; |
| 54 | |
| 55 | static { |
| 56 | if(logging)System.out.println("os:" + System.getProperty("os.name")); |
| 57 | if(logging)System.out.println("dpr:" + Toolkit.getDefaultToolkit().getScreenResolution()); |
| 58 | } |
| 59 | |
| 60 | String test = " 34567890\n1234567890\n 345\n "; |
| 61 | |
| 62 | private static void logClass(String name) { |
| 63 | ConsoleHandler consoleHandler = new ConsoleHandler(); |
| 64 | consoleHandler.setLevel(Level.ALL); |
| 65 | Logger logger = Logger.getLogger(name); |
| 66 | logger.setLevel(Level.ALL); |
| 67 | logger.addHandler(consoleHandler); |
| 68 | } |
| 69 | |
| 70 | private static boolean allowLogging = true; |
| 71 | private static boolean allowEventInfo = true; |
| 72 | |
| 73 | private void setLogging() { |
| 74 | if ((/** @j2sNative false && */ |
| 75 | allowLogging)) { |
| 76 | |
| 77 | Logger rootLogger = Logger.getLogger(""); |
| 78 | rootLogger.setLevel(Level.ALL); |
| 79 | logClass("java.awt.EventDispatchThread"); |
| 80 | logClass("java.awt.EventQueue"); |
| 81 | logClass("java.awt.Component"); |
| 82 | logClass("java.awt.focus.Component"); |
| 83 | logClass("java.awt.focus.DefaultKeyboardFocusManager"); |
| 84 | |
| 85 | } |
| 86 | |
| 87 | } |
| 88 | |
| 89 | public static void main(String[] args) { |
| 90 | KeyboardFocusManager.setCurrentKeyboardFocusManager(new DefaultKeyboardFocusManager() { |
| 91 | @Override |
| 92 | public boolean dispatchEvent(AWTEvent e) { |
| 93 | if (allowEventInfo && e.getID() != MouseEvent.MOUSE_MOVED) { |
| 94 | if (e.getID() == MouseEvent.MOUSE_PRESSED) { // |
| 95 | if(logging)System.out.println("FocusMan mousepressed event"); |
| 96 | } |
| 97 | if(logging)System.out.println("FocusMan dispatching activeElement=" + (/** @j2sNative document.activeElement.id || */getFocusOwner())); |
| 98 | if(logging)System.out.println("FocusMan dispatching event Source " + e.getSource()); |
| 99 | if (e.toString().indexOf("WINDOW_OPENED")>=0) { |
| 100 | if(logging)System.out.println("???"); |
| 101 | } |
| 102 | // if (e.toString().indexOf("GAINED") >= 0) |
| 103 | if(logging)System.out.println("FocusMan dispatching event " + e); |
| 104 | } |
| 105 | return super.dispatchEvent(e); |
nothing calls this directly
no test coverage detected