guicomponents

## Class GWindow

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - java.awt.Window
      - - java.awt.Frame
        - - guicomponents.GWindow

- All Implemented Interfaces:
    GConstants, ImageObserver, MenuContainer, Serializable, Accessible

      public class GWindow
      extends Frame
      implements GConstants

  Objects of this class are separate windows which can be used to hold G4P GUI components or used for drawing or both combined.
  A number of examples are included in the library and can be found at www.lagers.org.uk
  Author:
    Peter Lager
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.awt.Window

      `Window.Type`

    - ### Nested classes/interfaces inherited from class java.awt.Component

      `Component.BaselineResizeBehavior`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `GWinData` | `data`
    `Method` | `mouseHandlerMethod` The method in mouseHandlerObject to execute
    `Object` | `mouseHandlerObject` The object to handle the mouse event
    `GWinApplet` | `papplet` Gives direct access to the PApplet object inside the frame

    - ### Fields inherited from class java.awt.Frame

      `CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR`

    - ### Fields inherited from class java.awt.Component

      `BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

    - ### Fields inherited from interface guicomponents.GConstants

      `ADD_DUPLICATE, BACKGROUND, CHANGED, CLICKED, CLOSE_WINDOW, COLLAPSED, CTRL_ANGULAR, CTRL_HORIZONTAL, CTRL_VERTICAL, DESELECTED, DISABLE_AUTO_DRAW, DRAGGED, ENTERED, EXCP_IN_HANDLER, EXIT_APP, EXPANDED, FAMILY, FOREGROUND, HUD_UNSUPPORTED, INVALID_STATUS, JUSTIFICATION, JUSTIFICATION_FULL, JUSTIFICATION_NONE, KEEP_OPEN, MISSING, NONEXISTANT, NOT_PEASYCAM, POSTURE, POSTURE_OBLIQUE, POSTURE_REGULAR, PRESSED, RELEASED, RUNTIME_ERROR, SCROLL_DOWN, SCROLL_LEFT, SCROLL_RIGHT, SCROLL_UP, SCROLLBAR_HORIZONTAL, SCROLLBAR_VERTICAL, SCROLLBARS_AUTOHIDE, SCROLLBARS_BOTH, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, SCROLLBARS_VERTICAL_ONLY, SELECTED, SET, SIZE, STRIKETHROUGH, STRIKETHROUGH_OFF, STRIKETHROUGH_ON, SUPERSCRIPT, SUPERSCRIPT_SUB, SUPERSCRIPT_SUPER, USER_COL_SCHEME, WEIGHT, WEIGHT_BOLD, WEIGHT_DEMIBOLD, WEIGHT_DEMILIGHT, WEIGHT_EXTRA_LIGHT, WEIGHT_EXTRABOLD, WEIGHT_HEAVY, WEIGHT_LIGHT, WEIGHT_MEDIUM, WEIGHT_REGULAR, WEIGHT_SEMIBOLD, WEIGHT_ULTRABOLD, WIDTH, WIDTH_CONDENSED, WIDTH_EXTENDED, WIDTH_REGULAR, WIDTH_SEMI_CONDENSED, WIDTH_SEMI_EXTENDED`

    - ### Fields inherited from interface java.awt.image.ImageObserver

      `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GWindow(PApplet theApplet, String name, int x, int y, int w, int h, boolean noFrame, String mode)` Create a window that can be used to hold G4P components or used for drawing or both together.
    `GWindow(PApplet theApplet, String name, int x, int y, PImage image, boolean noFrame, String mode)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(GComponent component)` Add a G4P component onto the window.
    `void` | `addData(GWinData data)` Add an object that holds the data this window needs to use.
    `void` | `addDrawHandler(Object obj, String methodName)` Attempt to add the 'draw' handler method.
    `void` | `addMouseHandler(Object obj, String methodName)` Attempt to add the 'mouse' handler method.
    `void` | `addPostHandler(Object obj, String methodName)` Attempt to add the 'post' handler method.
    `void` | `addPreHandler(Object obj, String methodName)` Attempt to add the 'pre' handler method.
    `void` | `close()` Allows the user to close this window and release its resources.
    `int` | `getActionOnClose()` Get the action to be performed when the user attempts to close the window.
    `void` | `setActionOnClose(int action)` This sets what happens when the users attempts to close the window.
    `void` | `setAutoClear(boolean auto_clear)` By default the background() method is called to set the background image/colour every frame.
    `void` | `setBackground(int col)` Set the background color for the window.
    `void` | `setBackground(PImage image)` Set the background image to be used instead of a plain color background The window will resize to accommodate the image.
    `void` | `setLocation(int x, int y)` Sets the location of the window.
    `void` | `setOnTop(boolean onTop)` Always make this window appear on top of other windows (or not).
    `void` | `setResizable(boolean resizable)` Determines whether the window is resizabale or not.
    `void` | `setVisible(boolean visible)` Sets the visibility of the window (Already available from the Frame class - helps visibility of method in G4P reference)

    - ### Methods inherited from class java.awt.Frame

      `addNotify, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setOpacity, setShape, setState, setTitle, setUndecorated`

    - ### Methods inherited from class java.awt.Window

      `addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, show, toBack, toFront`

    - ### Methods inherited from class java.awt.Container

      `add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate`

    - ### Methods inherited from class java.awt.Component

      `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.awt.MenuContainer

      `getFont, postEvent`

- - ### Field Detail

    - #### papplet

          public GWinApplet papplet

      Gives direct access to the PApplet object inside the frame

    - #### data

          public GWinData data

    - #### mouseHandlerObject

          public Object mouseHandlerObject

      The object to handle the mouse event

    - #### mouseHandlerMethod

          public Method mouseHandlerMethod

      The method in mouseHandlerObject to execute

  - ### Constructor Detail

    - #### GWindow

          public GWindow(PApplet theApplet,
                 String name,
                 int x,
                 int y,
                 int w,
                 int h,
                 boolean noFrame,
                 String mode)

      Create a window that can be used to hold G4P components or used for drawing or both together.
      Parameters:
        `theApplet` -
        `name` -
        `x` - initial position on the screen
        `y` - initial position on the screen
        `w` - width of the drawing area (the frame will be bigger to accommodate border)
        `h` - height of the drawing area (the frame will be bigger to accommodate border and title bar)
        `noFrame` - if true then the frame has no border
        `mode` - JAVA2D / P2D / P3D / OPENGL

    - #### GWindow

          public GWindow(PApplet theApplet,
                 String name,
                 int x,
                 int y,
                 PImage image,
                 boolean noFrame,
                 String mode)

      Parameters:
        `theApplet` -
        `name` -
        `x` - initial position on the screen
        `y` - initial position on the screen
        `image` - background image (used to size window)
        `noFrame` - if true then the frame has no border
        `mode` - JAVA2D / P2D / P3D / OPENGL

  - ### Method Detail

    - #### add

          public void add(GComponent component)

      Add a G4P component onto the window.
      Parameters:
        `component` -

    - #### addData

          public void addData(GWinData data)

      Add an object that holds the data this window needs to use. Note: the object can be of any class that extends GWinData.
      Parameters:
        `data` -

    - #### setOnTop

          public void setOnTop(boolean onTop)

      Always make this window appear on top of other windows (or not).
      This will not work when run from a remote server (ie Applet over the web) for security reasons. In this situation a call to this method is ignored and a warning is generated.
      Parameters:
        `onTop` -

    - #### setLocation

          public void setLocation(int x,
                         int y)

      Sets the location of the window.
      (Already available from the Frame class - helps visibility of method in G4P reference)
      Overrides:
        `setLocation` in class `Window`

    - #### setVisible

          public void setVisible(boolean visible)

      Sets the visibility of the window
      (Already available from the Frame class - helps visibility of method in G4P reference)
      Overrides:
        `setVisible` in class `Window`

    - #### setResizable

          public void setResizable(boolean resizable)

      Determines whether the window is resizabale or not.
      This cannot be set to true if a background image is used.
      Overrides:
        `setResizable` in class `Frame`

    - #### setBackground

          public void setBackground(PImage image)

      Set the background image to be used instead of a plain color background
      The window will resize to accommodate the image.
      Parameters:
        `image` -

    - #### setBackground

          public void setBackground(int col)

      Set the background color for the window.
      Parameters:
        `col` -

    - #### setAutoClear

          public void setAutoClear(boolean auto_clear)

      By default the background() method is called to set the background image/colour every frame. You can switch this off by calling this method with a parametr value = false.
      Parameters:
        `auto_clear` - whether to call the background method() or not

    - #### setActionOnClose

          public void setActionOnClose(int action)

      This sets what happens when the users attempts to close the window.
      There are 3 possible actions depending on the value passed.
      GWindow.KEEP_OPEN - ignore attempt to close window (default action) GWindow.CLOSE_WINDOW - close this window, if it is the main window it causes the app to exit
      GWindow.EXIT_APP - exit the app, this will cause all windows to close.
      Parameters:
        `action` -

    - #### getActionOnClose

          public int getActionOnClose()

      Get the action to be performed when the user attempts to close the window.
      Returns:
        actionOnClose

    - #### close

          public void close()

      Allows the user to close this window and release its resources.

    - #### addDrawHandler

          public void addDrawHandler(Object obj,
                            String methodName)

      Attempt to add the 'draw' handler method. The default event handler is a method that returns void and has two parameters Papplet and GWinData
      Parameters:
        `obj` - the object to handle the event
        `methodName` - the method to execute in the object handler class

    - #### addPreHandler

          public void addPreHandler(Object obj,
                           String methodName)

      Attempt to add the 'pre' handler method. The default event handler is a method that returns void and has two parameters Papplet and GWinData
      Parameters:
        `obj` - the object to handle the event
        `methodName` - the method to execute in the object handler class

    - #### addMouseHandler

          public void addMouseHandler(Object obj,
                             String methodName)

      Attempt to add the 'mouse' handler method. The default event handler is a method that returns void and has two parameters Papplet and GWinData
      Parameters:
        `obj` - the object to handle the event
        `methodName` - the method to execute in the object handler class

    - #### addPostHandler

          public void addPostHandler(Object obj,
                            String methodName)

      Attempt to add the 'post' handler method. The default event handler is a method that returns void and has two parameters Papplet and GWinData
      Parameters:
        `obj` - the object to handle the event
        `methodName` - the method to execute in the object handler class

Processing library guicomponents by Peter Lager. (C) 2012