public void windowClosing(WindowEvent evt) { switch (actionOnClose) { case CLOSE_WINDOW: window.papplet.noLoop(); G4P.markWindowForClosure(window); break; case EXIT_APP: System.exit(0); break; } }
/** * Create an option button with text. * * @param theApplet that will display the control * @param p0 * @param p1 * @param p2 * @param p3 * @param text text to be displayed */ public GOption(PApplet theApplet, float p0, float p1, float p2, float p3, String text) { super(theApplet, p0, p1, p2, p3); opaque = false; setText(text); setIcon("pinhead.png", 2, GAlign.LEFT, null); setTextAlign(GAlign.LEFT, null); z = Z_SLIPPY; // Now register control with applet createEventHandler( G4P.sketchWindow, "handleToggleControlEvents", new Class<?>[] {GToggleControl.class, GEvent.class}, new String[] {"option", "event"}); registeredMethods = DRAW_METHOD | MOUSE_METHOD; cursorOver = HAND; G4P.registerControl(this); }
public GScrollbar(PApplet theApplet, float p0, float p1, float p2, float p3) { super(theApplet, p0, p1, p2, p3); buffer = (PGraphicsJava2D) winApp.createGraphics((int) width, (int) height, PApplet.JAVA2D); buffer.rectMode(PApplet.CORNER); hotspots = new HotSpot[] { new HSrect(1, 0, 0, 16, height), // low cap new HSrect(2, width - 16, 0, 16, height), // high cap new HSrect(9, 17, 0, width - 17, height) // thumb track }; lowCap = new RoundRectangle2D.Float(1, 1, 15, height - 2, 6, 6); highCap = new RoundRectangle2D.Float(width - 15, 1, 14.5f, height - 2, 6, 6); opaque = false; z = Z_SLIPPY; registeredMethods = DRAW_METHOD | MOUSE_METHOD; cursorOver = HAND; G4P.addControl(this); }
/** * Core stuff for GWindows ctor * * @param x * @param y * @param w * @param h * @param noFrame * @param mode */ private void windowCtorCore( PApplet theApplet, int x, int y, int w, int h, PImage image, boolean noFrame, String mode, String name) { // If this is the first control to be created then theAapplet must be the sketchApplet if (G4P.sketchApplet == null) G4P.sketchApplet = theApplet; app = theApplet; winName = name; if (mode == null || mode.equals("")) mode = PApplet.JAVA2D; papplet = new GWinApplet(mode); papplet.owner = this; papplet.frame = this; // So we can resize the frame to get the sketch canvas size reqd. papplet.frame.setResizable(true); // Now set the window width and height if (image == null) { papplet.appWidth = w; papplet.appHeight = h; } else { papplet.bkImage = image; papplet.appWidth = image.width; papplet.appHeight = image.height; } papplet.bkColor = papplet.color(180); // Set the papplet size preferences papplet.resize(papplet.appWidth, papplet.appHeight); papplet.setPreferredSize(new Dimension(papplet.appWidth, papplet.appHeight)); papplet.setMinimumSize(new Dimension(papplet.appWidth, papplet.appHeight)); // add the PApplet to the Frame setLayout(new BorderLayout()); add(papplet, BorderLayout.CENTER); // ensures that the animation thread is started and // that other internal variables are properly set. papplet.init(); // Set the sketch path to the same as the main PApplet object papplet.sketchPath = theApplet.sketchPath; // Pack the window, position it and make visible setUndecorated(noFrame); pack(); setLocation(x, y); setVisible(true); // Make the window always on top setOnTop(true); // Make sure we have some data even if not used data = new GWinData(); data.owner = this; // Not resizeable if we are using a back image super.setResizable(image == null); // Make sure G4P knows about this window G4P.addWindow(this); }