Toolkit

processing.app

## Class Toolkit

- Object
- - Toolkit

-     public class Toolkit
      extends Object

  Utility functions for base that require a java.awt.Toolkit object. These are broken out from Base as we start moving toward the possibility of the code running in headless mode.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static KeyStroke` | `WINDOW_CLOSE_KEYSTROKE` Command-W on Mac OS X, Ctrl-W on Windows and Linux

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Toolkit()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addDisabledItem(JMenu menu, String title)`
    `static void` | `beep()`
    `static Image` | `getLibImage(String filename)` Return an Image object from inside the Processing lib folder.
    `static Font` | `getMonoFont(int size, int style)`
    `static String[]` | `getMonoFontFamilies()`
    `static String` | `getMonoFontName()`
    `static Font` | `getSansFont(int size, int style)`
    `static Dimension` | `getScreenSize()`
    `static Clipboard` | `getSystemClipboard()`
    `static boolean` | `highResDisplay()`
    `static JCheckBoxMenuItem` | `newJCheckBoxMenuItem(String title, int what)`
    `static JMenuItem` | `newJMenuItem(String title, int what)` A software engineer, somewhere, needs to have his abstraction taken away.
    `static JMenuItem` | `newJMenuItemAlt(String title, int what)` Same as newJMenuItem(), but adds the ALT (on Linux and Windows) or OPTION (on Mac OS X) key as a modifier.
    `static JMenuItem` | `newJMenuItemShift(String title, int what)` Like newJMenuItem() but adds shift as a modifier for the shortcut.
    `static void` | `registerWindowCloseKeys(JRootPane root, ActionListener disposer)` Registers key events for a Ctrl-W and ESC with an ActionListener that will take care of disposing the window.
    `static void` | `setIcon(Frame frame)` Give this Frame the Processing icon set.

    - ### Methods inherited from class Object

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

- - ### Field Detail

    - #### WINDOW_CLOSE_KEYSTROKE

          public static final KeyStroke WINDOW_CLOSE_KEYSTROKE

      Command-W on Mac OS X, Ctrl-W on Windows and Linux

  - ### Constructor Detail

    - #### Toolkit

          public Toolkit()

  - ### Method Detail

    - #### newJMenuItem

          public static JMenuItem newJMenuItem(String title,
                               int what)

      A software engineer, somewhere, needs to have his abstraction taken away. In some countries they jail or beat people for crafting the sort of API that would require a five line helper function just to set the shortcut key for a menu item.

    - #### newJMenuItemShift

          public static JMenuItem newJMenuItemShift(String title,
                                    int what)

      Like newJMenuItem() but adds shift as a modifier for the shortcut.

    - #### newJMenuItemAlt

          public static JMenuItem newJMenuItemAlt(String title,
                                  int what)

      Same as newJMenuItem(), but adds the ALT (on Linux and Windows) or OPTION (on Mac OS X) key as a modifier.

    - #### newJCheckBoxMenuItem

          public static JCheckBoxMenuItem newJCheckBoxMenuItem(String title,
                                               int what)

    - #### addDisabledItem

          public static void addDisabledItem(JMenu menu,
                             String title)

    - #### getScreenSize

          public static Dimension getScreenSize()

    - #### getLibImage

          public static Image getLibImage(String filename)

      Return an Image object from inside the Processing lib folder. Moved here so that Base can stay headless.

    - #### setIcon

          public static void setIcon(Frame frame)

      Give this Frame the Processing icon set. Ignored on OS X, because they thought different and made this function set the minified image of the window, not the window icon for the dock or cmd-tab.

    - #### registerWindowCloseKeys

          public static void registerWindowCloseKeys(JRootPane root,
                                     ActionListener disposer)

      Registers key events for a Ctrl-W and ESC with an ActionListener that will take care of disposing the window.

    - #### beep

          public static void beep()

    - #### getSystemClipboard

          public static Clipboard getSystemClipboard()

    - #### highResDisplay

          public static boolean highResDisplay()

    - #### getMonoFontFamilies

          public static String[] getMonoFontFamilies()

    - #### getMonoFontName

          public static String getMonoFontName()

    - #### getMonoFont

          public static Font getMonoFont(int size,
                         int style)

    - #### getSansFont

          public static Font getSansFont(int size,
                         int style)