import com.sun.glass.ui.*; import com.sun.glass.events.*; public class glass implements Runnable { public static void main(String[] args) { Application.run(new glass()); } Window w, p, w2; public void run() { Application app = Application.GetApplication(); w = app.createWindow(null, Screen.getMainScreen(), Window.TITLED); w.setTitle("Click the client area"); w.setPosition(100, 100); w.setSize(300, 300); w.setBackground(0, 1.0f, 0); w.setEventHandler(new Window.EventHandler() { public void handleWindowEvent(Window window, long time, int type) { if (type == WindowEvent.FOCUS_UNGRAB) { p.close(); w.requestFocus(); } if (type == WindowEvent.FOCUS_LOST) System.err.println("w FOCUS_LOST"); if (type == WindowEvent.FOCUS_GAINED) System.err.println("w FOCUS_GAINED"); } }); View vw = app.createView(); vw.setEventHandler(new View.EventHandler() { public void handleKeyEvent(View view, long time, int action, int keyCode, char[] keyChars, int modifiers) { if (action == KeyEvent.PRESS) w.setTitle("" + keyCode); } public void handleMouseEvent(View view, long time, int type, int button, int x, int y, int xAbs, int yAbs, int modifiers, boolean isPopupTrigger, boolean isSynthesized) { if (type == MouseEvent.UP) { p = app.createWindow(w, w.getScreen(), Window.TITLED); p.setTitle("Click the popup's client area"); p.setPosition(xAbs, yAbs); p.setSize(400, 200); p.setBackground(1.0f, 0, 0); p.setFocusable(false); View vp = app.createView(); vp.setEventHandler(new View.EventHandler() { public void handleMouseEvent(View view, long time, int type, int button, int x, int y, int xAbs, int yAbs, int modifiers, boolean isPopupTrigger, boolean isSynthesized) { if (type == MouseEvent.UP) { w2 = app.createWindow(null, Screen.getMainScreen(), Window.TITLED); w2.setEventHandler(new Window.EventHandler() { public void handleWindowEvent(Window window, long time, int type) { if (type == WindowEvent.FOCUS_LOST) System.err.println("w2 FOCUS_LOST"); if (type == WindowEvent.FOCUS_GAINED) System.err.println("w2 FOCUS_GAINED"); } }); w2.setTitle("Press keys and watch windows' titles"); w2.setPosition(300, 200); w2.setSize(300, 300); w2.setBackground(0, 0, 1.0f); View v2 = app.createView(); v2.setEventHandler(new View.EventHandler() { public void handleKeyEvent(View view, long time, int action, int keyCode, char[] keyChars, int modifiers) { if (action == KeyEvent.PRESS) w2.setTitle("" + keyCode); } }); w2.setView(v2); w2.requestFocus(); w2.setVisible(true); } } }); p.setView(vp); w.grabFocus(); p.setVisible(true); } } }); w.setView(vw); w.setVisible(true); } }