public class Toolkit
extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BORDER |
static KeyStroke |
WINDOW_CLOSE_KEYSTROKE
Command-W on Mac OS X, Ctrl-W on Windows and Linux
|
Constructor and Description |
---|
Toolkit() |
Modifier and Type | Method and Description |
---|---|
static void |
addDisabledItem(JMenu menu,
String title) |
static void |
beep() |
static JButton |
createIconButton(String base)
Same as above, but with no text title (follows JButton constructor)
|
static JButton |
createIconButton(String title,
Icon icon) |
static JButton |
createIconButton(String title,
String base)
Create a JButton with an icon, and set its disabled and pressed images
to be the same image, so that 2x versions of the icon work properly.
|
static Shape |
createRoundRect(float x1,
float y1,
float x2,
float y2,
float tl,
float tr,
float br,
float bl) |
static double |
getAscent(Graphics g)
Synthesized replacement for FontMetrics.getAscent(), which is dreadfully
inaccurate and inconsistent across platforms.
|
static int |
getButtonWidth()
Standardized width for buttons.
|
static ImageIcon |
getIconX(File dir,
String base) |
static ImageIcon |
getIconX(File dir,
String base,
int size)
Get an icon of the format base-NN.png where NN is the size, but if it's
a hidpi display, get the NN*2 version automatically, sized at NN
|
static KeyStroke |
getKeyStrokeExt(String base)
Return the correct KeyStroke per locale and platform.
|
static ImageIcon |
getLibIcon(String filename)
Get an ImageIcon from the Processing 'lib' folder.
|
static ImageIcon |
getLibIconX(String base)
Get an image icon with hi-dpi support.
|
static ImageIcon |
getLibIconX(String base,
int size) |
static Image |
getLibImage(String filename)
Return an Image object from inside the Processing 'lib' folder.
|
static int |
getMenuItemIndex(JMenu menu,
JMenuItem item) |
static Font |
getMonoFont(int size,
int style) |
static String[] |
getMonoFontFamilies() |
static String |
getMonoFontName() |
static Font |
getSansFont(int size,
int style) |
static String |
getSansFontName() |
static Dimension |
getScreenSize() |
static Clipboard |
getSystemClipboard() |
static boolean |
highResImages() |
static boolean |
isRetina() |
static JCheckBoxMenuItem |
newJCheckBoxMenuItem(String title,
int what) |
static JMenuItem |
newJMenuItem(Action action,
int what) |
static JMenuItem |
newJMenuItem(String title,
int what)
A software engineer, somewhere, needs to have their 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 |
newJMenuItemExt(String base)
Create a menu item and set its KeyStroke by name (so it can be stored
in the language settings or the preferences.
|
static JMenuItem |
newJMenuItemShift(Action action,
int what)
Like newJMenuItem() but adds shift as a modifier for the shortcut.
|
static JMenuItem |
newJMenuItemShift(String title,
int what)
Like newJMenuItem() but adds shift as a modifier for the shortcut.
|
static Image |
offscreenGraphics(Component comp,
int width,
int height)
Create an Image to be used as an offscreen drawing context,
automatically doubling the size if running on a retina display.
|
static Graphics2D |
prepareGraphics(Graphics g)
Handles scaling for high-res displays, also sets text anti-aliasing
options to be far less ugly than the defaults.
|
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 |
setBorder(JComponent comp) |
static void |
setBorder(JComponent comp,
int top,
int left,
int bottom,
int right) |
static void |
setIcon(Frame frame) |
static void |
setIcon(Window window)
Give this Frame the Processing icon set.
|
static void |
setMenuMnemonics(JMenuBar menubar)
As setMenuMnemonics(JMenuItem...).
|
static void |
setMenuMnemonics(JMenuItem... menu)
Removes all mnemonics, then sets a mnemonic for each menu and menu item
recursively by these rules:
It tries to assign one of
KDE's defaults.
Failing that, it loops through the first letter of each word, where a word
is a block of Unicode "alphabetical" chars, looking for an upper-case ASCII mnemonic
that is not taken.
|
static void |
setMenuMnemonics(JPopupMenu menu)
As setMenuMnemonics(JMenuItem...).
|
static void |
setMenuMnemsInside(JMenu menu)
Calls setMenuMnemonics(JMenuItem...) on the sub-elements only.
|
static int |
zoom(int pixels) |
static Dimension |
zoom(int w,
int h) |
public static final KeyStroke WINDOW_CLOSE_KEYSTROKE
public static final int BORDER
public static int getButtonWidth()
public static KeyStroke getKeyStrokeExt(String base)
base
- the localization key for the menu item
(.keystroke and .platform will be added to the end)public static JMenuItem newJMenuItemExt(String base)
sequence
- the name, as outlined by the KeyStroke APIfallback
- what to use if getKeyStroke() comes back nullpublic static JMenuItem newJMenuItem(String title, int what)
public static JMenuItem newJMenuItem(Action action, int what)
action:
- use an Action, which sets the title, reaction
and enabled-ness all by itself.public static JMenuItem newJMenuItemShift(String title, int what)
public static JMenuItem newJMenuItemShift(Action action, int what)
public static JMenuItem newJMenuItemAlt(String title, int what)
public static JCheckBoxMenuItem newJCheckBoxMenuItem(String title, int what)
public static void addDisabledItem(JMenu menu, String title)
public static void setMenuMnemonics(JMenuItem... menu)
menu
- A menu, a list of menus or an array of menu items to set mnemonics for.public static void setMenuMnemonics(JMenuBar menubar)
public static void setMenuMnemonics(JPopupMenu menu)
public static void setMenuMnemsInside(JMenu menu)
public static Dimension getScreenSize()
public static Image getLibImage(String filename)
public static ImageIcon getLibIcon(String filename)
public static ImageIcon getIconX(File dir, String base)
public static ImageIcon getIconX(File dir, String base, int size)
public static ImageIcon getLibIconX(String base)
public static ImageIcon getLibIconX(String base, int size)
public static JButton createIconButton(String title, String base)
public static JButton createIconButton(String base)
public static JButton createIconButton(String title, Icon icon)
public static void setIcon(Frame frame)
public static void setIcon(Window window)
public static Shape createRoundRect(float x1, float y1, float x2, float y2, float tl, float tr, float br, float bl)
public static void registerWindowCloseKeys(JRootPane root, ActionListener disposer)
public static void beep()
public static Clipboard getSystemClipboard()
public static Image offscreenGraphics(Component comp, int width, int height)
public static Graphics2D prepareGraphics(Graphics g)
public static int zoom(int pixels)
public static Dimension zoom(int w, int h)
public static void setBorder(JComponent comp)
public static void setBorder(JComponent comp, int top, int left, int bottom, int right)
public static boolean highResImages()
public static boolean isRetina()
public static String[] getMonoFontFamilies()
public static String getMonoFontName()
public static Font getMonoFont(int size, int style)
public static String getSansFontName()
public static Font getSansFont(int size, int style)
public static double getAscent(Graphics g)
public static int getMenuItemIndex(JMenu menu, JMenuItem item)