public class GuiUtilities extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ACTION_MAP_KEY_COPY
Standard Java Action map key for Edit -> Copy.
|
static String |
ACTION_MAP_KEY_CUT
Standard Java Action map key for Edit -> Cut.
|
static String |
ACTION_MAP_KEY_DELETE
Standard Java Action map key for Edit -> Delete.
|
static String |
ACTION_MAP_KEY_PASTE
Standard Java Action map key for Edit -> Paste.
|
static String |
ACTION_MAP_KEY_REDO
Geneious Action map key for Edit -> Redo.
|
static String |
ACTION_MAP_KEY_SELECT_ALL
Standard Java Action map key for Edit -> Select All on anything but a JTable.
|
static String |
ACTION_MAP_KEY_SELECT_ALL_TABLE
Standard Java Action map key for Edit -> Select All on a JTable.
|
static String |
ACTION_MAP_KEY_UNDO
Geneious Action map key for Edit -> Undo.
|
static String |
ALT_KEY_STRING
System-dependent string used to represent the ALT key
|
static Color |
CLEAR
Clear color,
new Color(0,0,0,0) |
static char |
COMMAND_KEY_CHAR
The character used to represent the command key on Apple Macs (the "cloverleaf").
|
static String |
CTRL_KEY_STRING
System-dependent string used to represent the CTRL key
|
static DataFlavor |
DOCUMENT_LIST_FLAVOR
The DataFlavor that Geneious creates for drag-and-drop events containing Annotated Plugin Documents.
|
static String |
ENTER_KEY_STRING
System-dependent string used to represent the ENTER/RETURN key
|
static int |
MENU_MASK
The key modifier for the Ctrl key on all operating systems except Mac OS, on which it is the Command key.
|
static String |
META_KEY_STRING
System-dependent string used to represent the META key
|
static String |
SHIFT_KEY_STRING
System-dependent string used to represent the SHIFT key
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addEditMenuSupport(JTextComponent component)
Links a
JTextComponent to the Edit menu actions Cut, Copy, Paste and Select All. |
static void |
addPopupEditMenu(JTextComponent component)
Add a popup menu to a
JTextComponent which contains the standard Edit menu actions Cut, Copy, Paste,
Select All, Undo and Redo. |
static void |
addUndoSupport(JTextComponent component)
Add Undo and Redo capability to a
JTextComponent. |
static Cursor |
createCustomCursor(Icon icon,
String name,
int hotspotx,
int hotspoty)
Create a cursor from an icon.
|
static GButton |
createHelpButton() |
static GButton |
createHelpButton(boolean smallButton) |
static GButton |
createHelpButton(boolean smallButton,
String title,
String message)
Creates a help style button that displays a help dialog with when clicked on
|
static GButton |
createHelpButton(String title,
String message)
Creates a help style button that displays a help dialog with when clicked on
|
static Rectangle |
ensureRectangleIsWithinBounds(Rectangle rectangle,
Rectangle maximumBounds)
If the given rectangle is not completely contained within maximumBounds then move it the smallest possible distance
so that it is.
|
static void |
ensureWindowIsOnScreen(Window window)
If the given window is not completely contained within a single screen then move it the smallest possible distance
so that it is.
|
static Point |
getAbsoluteMouseLocation()
Returns the Point that represents the coordinates of the mouse pointer on the screen.
|
static Rectangle |
getBoundsOfMonitorThatRectangleIsMostlyIn(Rectangle rectangle)
Find the bounds of the monitor that the majority of the supplied rectangle intersects with and return that monitor's bounds, which excludes the task bar.
|
static String |
getDialogHtmlHead()
Get an HTML <head>...</head> block that should be used for any text pane shown in a dialog.
|
static Color |
getDisabledLabelForegroundColor()
Equivalent to calling UIManager.getColor("Label.disabledForeground") except that it returns Color.GRAY if the
former would return null
|
static String |
getHtmlHead()
Get an HTML <head>...</head> block that can be included in
displayed HTML pages.
|
static String |
getHtmlStylesheet()
Get the CSS HTML stylesheet used throughout Geneious when displaying
HTML.
|
static Point |
getLocationRelativeToRootPane(Component component)
Get the location of the given component relative to the root pane of the component.
|
static AbstractFrame |
getMainFrame()
Get the main Geneious frame (which contains the service tree, document table etc).
|
static Font |
getStandardDialogFont()
Get the standard font that is used to render text in dialogs.
|
static String |
getStringForKeyStroke(KeyStroke shortcut)
Get a string representation for a KeyStroke which can be displayed to the user eg.
|
static Color |
getUserSelectedColor(Color initialColor,
JComponent preview,
String dialogTitle)
gets a color selected by the user in a color chooser dialog.
|
static Color |
getUserSelectedColor(Color initialColor,
JComponent preview,
String dialogTitle,
boolean showClearColorButton)
gets a color selected by the user in a color chooser dialog.
|
static void |
setMainFrame(AbstractFrame mainFrame)
Set the main Geneious frame.
|
public static final char COMMAND_KEY_CHAR
SystemUtilities.isMac(),
Constant Field Valuespublic static final String ALT_KEY_STRING
public static final String CTRL_KEY_STRING
public static final String SHIFT_KEY_STRING
public static final String ENTER_KEY_STRING
public static final String META_KEY_STRING
public static final int MENU_MASK
public static final DataFlavor DOCUMENT_LIST_FLAVOR
List<? extends AnnotatedPluginDocument>public static final String ACTION_MAP_KEY_CUT
public static final String ACTION_MAP_KEY_COPY
public static final String ACTION_MAP_KEY_PASTE
public static final String ACTION_MAP_KEY_DELETE
public static final String ACTION_MAP_KEY_UNDO
public static final String ACTION_MAP_KEY_REDO
public static final String ACTION_MAP_KEY_SELECT_ALL_TABLE
public static final String ACTION_MAP_KEY_SELECT_ALL
public static final Color CLEAR
new Color(0,0,0,0)public static String getHtmlStylesheet()
getHtmlHead()
which wraps the return value of this method in an HTML <head>...</head> block.getHtmlHead()public static String getHtmlHead()
getHtmlStylesheet().getHtmlStylesheet()public static String getDialogHtmlHead()
getStandardDialogFont()public static Font getStandardDialogFont()
public static Color getDisabledLabelForegroundColor()
public static Point getLocationRelativeToRootPane(Component component)
component - component to get location ofpublic static Rectangle getBoundsOfMonitorThatRectangleIsMostlyIn(Rectangle rectangle)
rectangle - the rectangle the find which monitor it is mostly withinpublic static void ensureWindowIsOnScreen(Window window)
window - the window to ensure is on screenpublic static Rectangle ensureRectangleIsWithinBounds(Rectangle rectangle, Rectangle maximumBounds)
rectangle - the rectangle to ensure is within boundsmaximumBounds - the maximum bounds to position the rectangle withinpublic static void addUndoSupport(JTextComponent component)
JTextComponent. These are invoked with Ctrl+Z and Ctrl+Shift+Z
respectively. To have these linked to a popup menu, call addPopupEditMenu(javax.swing.text.JTextComponent).
The component is linked to Undo and Redo in the Edit menu by this method.component - Text component to add undo capability to.addEditMenuSupport(javax.swing.text.JTextComponent),
(javax.swing.text.JTextComponent)public static void addEditMenuSupport(JTextComponent component)
JTextComponent to the Edit menu actions Cut, Copy, Paste and Select All.component - Text Component to add Edit menu support to.addPopupEditMenu(javax.swing.text.JTextComponent),
addUndoSupport(javax.swing.text.JTextComponent)public static void addPopupEditMenu(JTextComponent component)
JTextComponent which contains the standard Edit menu actions Cut, Copy, Paste,
Select All, Undo and Redo. Undo and Redo are only added if addUndoSupport(javax.swing.text.JTextComponent)
has previously been called with this component.component - Text component to add a popup menu to.addEditMenuSupport(javax.swing.text.JTextComponent),
addUndoSupport(javax.swing.text.JTextComponent)public static void setMainFrame(AbstractFrame mainFrame)
mainFrame - The main Geneious framepublic static AbstractFrame getMainFrame()
public static String getStringForKeyStroke(KeyStroke shortcut)
shortcut - KeyStroke to get the string representation ofpublic static Color getUserSelectedColor(Color initialColor, JComponent preview, String dialogTitle)
initialColor - the inital color for the dialog to display. If null is passed in, black will be used.preview - an optional component that goes at the bottom of the dialog to show a preview of the color to the user.
The chooser will call JComponent.setForeground(java.awt.Color) on the component when the selected color
has changed.dialogTitle - the title of the dialog that will be displayedpublic static Color getUserSelectedColor(Color initialColor, JComponent preview, String dialogTitle, boolean showClearColorButton)
initialColor - the inital color for the dialog to display. If null is passed in, black will be used.preview - an optional component that goes at the bottom of the dialog to show a preview of the color to the user.
The chooser will call JComponent.setForeground(java.awt.Color) on the component when the selected color
has changed.dialogTitle - the title of the dialog that will be displayedshowClearColorButton - adds a "Clear Color" button to the dialog which means CLEAR will be returned
immediately if this is clicked.CLEAR if the clear button was present and was clicked or null if canceledpublic static Cursor createCustomCursor(Icon icon, String name, int hotspotx, int hotspoty)
icon - Icon to create the cursor fromname - a localized description of the cursor, for Java Accessibility usehotspotx - hot spot's x position relative to top-left corner of the iconhotspoty - hot spot's y position relative to top-left corner of the iconpublic static GButton createHelpButton()
createHelpButton(String, String) instead.createHelpButton(String, String)public static GButton createHelpButton(boolean smallButton)
smallButton - true for the button to be smaller than a standard sized buttoncreateHelpButton(String, String) instead.createHelpButton(String, String)public static GButton createHelpButton(String title, String message)
title - the title of the dialog to display when the button is clicked onmessage - the contents of the dialog to display when the button is clicked oncreateHelpButton()public static GButton createHelpButton(boolean smallButton, String title, String message)
smallButton - true for the button to be smaller than a standard sized buttontitle - the title of the dialog to display when the button is clicked onmessage - the contents of the dialog to display when the button is clicked oncreateHelpButton()public static Point getAbsoluteMouseLocation()
MouseInfo.getPointerInfo()
for more information about coordinate calculation for multi-screen systems.