/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. */ import com.sun.glass.ui.*; import com.sun.glass.events.*; import java.util.Map; import java.util.HashMap; public class Simple implements Launchable { public static void main(String args[]) { Application.Run(args, "Simple", new Simple()); } public void finishLaunching(String[] args) { try { Application app = Application.GetApplication(); Window window = app.createWindow(Screen.getMainScreen(), Window.TITLED|Window.CLOSABLE); CloseEventHandler eventHandler = new CloseEventHandler(); window.setEventHandler(eventHandler); View view = app.createView(new NullGraphics()); window.setView(view); window.setBackground(1, 0, 0); window.setTitle("simple red Glass window"); window.setPosition(101, 102); window.setContentSize(514, 514); window.setVisible(true); } catch (Throwable t) { System.err.println(t); } } class CloseEventHandler extends Window.EventHandler { @Override public void handleWindowEvent(Window window, long time, int type) { if (type == WindowEvent.CLOSE) { Application.GetApplication().terminate(); } } } class NullGraphics extends Pen { @Override public Map getCapabilities() { return new HashMap(); } @Override public void paint(long time, int width, int height) { // NOP } } }