public class GUIUtilities
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GUIUtilities.UnixWorkaround |
Modifier and Type | Method and Description |
---|---|
static void |
addSizeSaver(java.awt.Frame frame,
java.awt.Container parent,
java.lang.String name)
Adds a SizeSaver to the specified Frame.
|
static void |
addSizeSaver(java.awt.Frame frame,
java.lang.String name)
Adds a SizeSaver to the specified Frame.
|
static void |
adjustForScreenBounds(java.awt.Rectangle desired)
Deprecated.
|
static void |
applyTextAreaColors(java.awt.Container win)
experimental - applies the text area colors on a Component
(such as a dockable window) and its children.
|
static int |
confirm(java.awt.Component comp,
java.lang.String name,
java.lang.Object[] args,
int buttons,
int type)
Displays a confirm dialog box and returns the button pushed by the
user.
|
static javax.swing.JComponent |
createMultilineLabel(java.lang.String str)
Creates a component that displays a multiple line message.
|
static int |
defaultColumnWidth()
Deprecated.
|
static int |
defaultRowHeight()
Deprecated.
|
static java.awt.Dimension |
defaultTableCellSize()
Deprecated.
|
static void |
error(java.awt.Component comp,
java.lang.String name,
java.lang.Object[] args)
Displays an error dialog box.
|
static java.awt.Component |
getComponentParent(java.awt.Component comp,
java.lang.Class clazz)
Finds a parent of the specified component.
|
static java.awt.Image |
getEditorIcon() |
static javax.swing.JDialog |
getParentDialog(java.awt.Component c)
Deprecated.
|
static java.lang.String |
getPlatformShortcutLabel(java.lang.String label)
Translates a shortcut description string (e.g.
|
static java.awt.Image |
getPluginIcon() |
static java.awt.Rectangle |
getScreenBounds()
Deprecated.
|
static java.util.List<javax.swing.JMenuItem> |
getServiceContextMenuItems(JEditTextArea textArea,
java.awt.event.MouseEvent evt) |
static java.lang.String |
getShortcutLabel(java.lang.String action,
java.lang.Boolean platform)
Returns a label string to show users what shortcut are
assigned to the action.
|
static java.lang.String |
getStyleString(SyntaxStyle style)
Converts a style into it's string representation.
|
static View |
getView(java.awt.Component comp)
Finds the view parent of the specified component.
|
static void |
hideSplashScreen()
Ensures that the splash screen is not visible.
|
static java.lang.String |
input(java.awt.Component comp,
java.lang.String name,
java.lang.Object def)
Displays an input dialog box and returns any text the user entered.
|
static java.lang.String |
input(java.awt.Component comp,
java.lang.String name,
java.lang.Object[] args,
java.lang.Object def)
Displays an input dialog box and returns any text the user entered.
|
static java.lang.String |
inputProperty(java.awt.Component comp,
java.lang.String name,
java.lang.Object[] args,
java.lang.String def)
Displays an input dialog box and returns any text the user entered.
|
static java.lang.String |
inputProperty(java.awt.Component comp,
java.lang.String name,
java.lang.String def)
Displays an input dialog box and returns any text the user entered.
|
static boolean |
isAncestorOf(java.awt.Component comp1,
java.awt.Component comp2)
Deprecated.
|
static boolean |
isMiddleButton(int modifiers)
Deprecated.
|
static boolean |
isPopupTrigger(java.awt.event.MouseEvent evt)
Deprecated.
|
static boolean |
isRightButton(int modifiers)
Deprecated.
|
static int |
listConfirm(java.awt.Component comp,
java.lang.String name,
java.lang.String[] args,
java.lang.Object[] listModel)
Displays a confirm dialog box and returns the button pushed by the
user.
|
static int |
listConfirm(java.awt.Component comp,
java.lang.String name,
java.lang.String[] args,
java.lang.Object[] listModel,
java.util.List selectedItems)
Displays a confirm dialog box and returns the button pushed by the
user.
|
static void |
loadGeometry(java.awt.Window win,
java.awt.Container parent,
java.lang.String name)
Loads a windows's geometry from the properties.
|
static void |
loadGeometry(java.awt.Window win,
java.lang.String name)
Loads a windows's geometry from the properties.
|
static javax.swing.Icon |
loadIcon(java.lang.String iconName)
Loads an icon.
|
static javax.swing.JMenu |
loadMenu(ActionContext context,
java.lang.String name)
Creates a menu.
|
static javax.swing.JMenu |
loadMenu(java.lang.String name)
Creates a menu.
|
static javax.swing.JMenuBar |
loadMenuBar(ActionContext context,
java.lang.String name)
Creates a menubar.
|
static javax.swing.JMenuBar |
loadMenuBar(java.lang.String name)
Creates a menubar.
|
static javax.swing.JMenuItem |
loadMenuItem(ActionContext context,
java.lang.String name,
boolean setMnemonic)
Creates a menu item.
|
static javax.swing.JMenuItem |
loadMenuItem(EditAction editAction,
boolean setMnemonic) |
static javax.swing.JMenuItem |
loadMenuItem(java.lang.String name)
Creates a menu item.
|
static javax.swing.JMenuItem |
loadMenuItem(java.lang.String name,
boolean setMnemonic)
Creates a menu item.
|
static javax.swing.JPopupMenu |
loadPopupMenu(ActionContext context,
java.lang.String name)
Creates a popup menu.
|
static javax.swing.JPopupMenu |
loadPopupMenu(ActionContext context,
java.lang.String name,
JEditTextArea textArea,
java.awt.event.MouseEvent evt)
Creates a popup menu.
|
static javax.swing.JPopupMenu |
loadPopupMenu(java.lang.String name) |
static javax.swing.JPopupMenu |
loadPopupMenu(java.lang.String name,
JEditTextArea textArea,
java.awt.event.MouseEvent evt)
Creates a popup menu.
|
static java.awt.Container |
loadToolBar(ActionContext context,
java.lang.String name)
Creates a toolbar.
|
static java.awt.Container |
loadToolBar(java.lang.String name) |
static EnhancedButton |
loadToolButton(ActionContext context,
java.lang.String name)
Loads a tool bar button.
|
static EnhancedButton |
loadToolButton(java.lang.String name)
Loads a tool bar button.
|
static void |
makeSameSize(java.awt.Component... components)
Deprecated.
|
static java.awt.Font |
menuAcceleratorFont()
Menu accelerator font according to L&F defaults, with workarounds.
|
static void |
message(java.awt.Component comp,
java.lang.String name,
java.lang.Object[] args)
Displays a dialog box.
|
static int |
option(java.awt.Component comp,
java.lang.String name,
java.lang.Object[] args,
int type,
java.lang.Object[] options,
java.lang.Object initialValue)
Displays an option dialog dialog box and returns the button pushed by the
user.
|
static java.awt.Color |
parseColor(java.lang.String name)
Deprecated.
|
static SyntaxStyle |
parseStyle(java.lang.String str,
java.lang.String family,
int size)
Deprecated.
|
static java.lang.String |
prettifyMenuLabel(java.lang.String label)
Deprecated.
|
static void |
requestFocus(java.awt.Window win,
java.awt.Component comp)
Deprecated.
|
static void |
saveGeometry(java.awt.Window win,
java.awt.Container parent,
java.lang.String name)
Saves a window's geometry to the properties.
|
static void |
saveGeometry(java.awt.Window win,
java.lang.String name)
Saves a window's geometry to the properties.
|
static void |
setAutoMnemonic(javax.swing.AbstractButton button)
Deprecated.
|
static void |
setButtonContentMargin(javax.swing.AbstractButton button,
java.awt.Insets margin)
|
static void |
setEnabledRecursively(java.awt.Container c,
boolean enabled)
Deprecated.
|
static void |
setIconPath(java.lang.String iconPath)
Sets the path where jEdit looks for icons.
|
static void |
showPopupMenu(javax.swing.JPopupMenu popup,
java.awt.Component comp,
int x,
int y)
|
static void |
showPopupMenu(javax.swing.JPopupMenu popup,
java.awt.Component comp,
int x,
int y,
boolean point)
|
static java.lang.String[] |
showVFSFileDialog(java.awt.Dialog parent,
View view,
java.lang.String path,
int type,
boolean multipleSelection)
Displays a VFS file selection dialog box.
|
static java.lang.String[] |
showVFSFileDialog(java.awt.Frame parent,
View view,
java.lang.String path,
int type,
boolean multipleSelection)
Displays a VFS file selection dialog box.
|
static java.lang.String[] |
showVFSFileDialog(View view,
java.lang.String path,
int type,
boolean multipleSelection)
Displays a VFS file selection dialog box.
|
public static void setIconPath(java.lang.String iconPath)
iconPath
- the icon pathpublic static javax.swing.Icon loadIcon(java.lang.String iconName)
iconName
- The icon namepublic static java.awt.Image getEditorIcon()
public static java.awt.Image getPluginIcon()
public static javax.swing.JMenuBar loadMenuBar(java.lang.String name)
name
- The menu bar namepublic static javax.swing.JMenuBar loadMenuBar(ActionContext context, java.lang.String name)
context
- An action contextname
- The menu bar namepublic static javax.swing.JMenu loadMenu(java.lang.String name)
name.label
property. The menu contents is taken
from the name
property, which is a whitespace
separated list of action names. An action name of -
inserts a separator in the menu.name
- The menu nameloadMenuItem(String)
public static javax.swing.JMenu loadMenu(ActionContext context, java.lang.String name)
name.label
property. The menu contents is taken
from the name
property, which is a whitespace
separated list of action names. An action name of -
inserts a separator in the menu.context
- An action context; either
jEdit.getActionContext()
or
VFSBrowser.getActionContext()
.name
- The menu nameloadMenuItem(String)
public static javax.swing.JPopupMenu loadPopupMenu(java.lang.String name, JEditTextArea textArea, java.awt.event.MouseEvent evt)
name
- The menu nameevt
- mouse eventtextArea
- the text areapublic static javax.swing.JPopupMenu loadPopupMenu(java.lang.String name)
name
- The menu namepublic static javax.swing.JPopupMenu loadPopupMenu(ActionContext context, java.lang.String name)
context
- An action context; either
jEdit.getActionContext()
or
VFSBrowser.getActionContext()
.name
- The menu namepublic static javax.swing.JPopupMenu loadPopupMenu(ActionContext context, java.lang.String name, JEditTextArea textArea, java.awt.event.MouseEvent evt)
context
- An action context; either
jEdit.getActionContext()
or
VFSBrowser.getActionContext()
.name
- The menu nametextArea
- the textArea wanting to show the popup.
If not null, include context menu items defined by services.evt
- additional context info about where the mouse was when menu was requestedpublic static java.util.List<javax.swing.JMenuItem> getServiceContextMenuItems(JEditTextArea textArea, java.awt.event.MouseEvent evt)
textArea
- the TextArea desiring to display these menu itemsevt
- a mouse eventpublic static javax.swing.JMenuItem loadMenuItem(java.lang.String name)
name
with label taken from the return value of the
EditAction.getLabel()
method.name
- The menu item nameloadMenu(String)
public static javax.swing.JMenuItem loadMenuItem(java.lang.String name, boolean setMnemonic)
name
- The menu item namesetMnemonic
- True if the menu item should have a mnemonicpublic static javax.swing.JMenuItem loadMenuItem(ActionContext context, java.lang.String name, boolean setMnemonic)
context
- An action context; either
jEdit.getActionContext()
or
VFSBrowser.getActionContext()
.name
- The menu item namesetMnemonic
- True if the menu item should have a mnemonicpublic static javax.swing.JMenuItem loadMenuItem(EditAction editAction, boolean setMnemonic)
public static java.awt.Container loadToolBar(java.lang.String name)
name
- The toolbar namepublic static java.awt.Container loadToolBar(ActionContext context, java.lang.String name)
context
- An action context; either
jEdit.getActionContext()
or
VFSBrowser.getActionContext()
.name
- The toolbar namepublic static EnhancedButton loadToolButton(java.lang.String name)
name.label
and
name.shortcut
properties and the icon is loaded
from the resource named '/org/gjt/sp/jedit/icons/' suffixed
with the value of the name.icon
property.name
- The name of the buttonpublic static EnhancedButton loadToolButton(ActionContext context, java.lang.String name)
name.label
and
name.shortcut
properties and the icon is loaded
from the resource named '/org/gjt/sp/jedit/icons/' suffixed
with the value of the name.icon
property.context
- An action context; either
jEdit.getActionContext()
or
VFSBrowser.getActionContext()
.name
- The name of the buttonpublic static java.lang.String prettifyMenuLabel(java.lang.String label)
GenericGUIUtilities.prettifyMenuLabel(String)
label
- the labelpublic static java.lang.String getPlatformShortcutLabel(java.lang.String label)
public static java.lang.String getShortcutLabel(java.lang.String action, java.lang.Boolean platform)
platform
- if true, show fancy platform-specific label for the modifiers.public static void setAutoMnemonic(javax.swing.AbstractButton button)
GenericGUIUtilities.setAutoMnemonic(AbstractButton)
button
- The button to set the mnemonic for.public static void message(java.awt.Component comp, java.lang.String name, java.lang.Object[] args)
name.title
property. The message is fetched
from the name.message
property. The message
is formatted by the property manager with args
as
positional parameters.comp
- The component to display the dialog forname
- The name of the dialogargs
- Positional parameters to be substituted into the
message textpublic static void error(java.awt.Component comp, java.lang.String name, java.lang.Object[] args)
name.title
property. The message is fetched
from the name.message
property. The message
is formatted by the property manager with args
as
positional parameters.comp
- The component to display the dialog forname
- The name of the dialogargs
- Positional parameters to be substituted into the
message textpublic static java.lang.String input(java.awt.Component comp, java.lang.String name, java.lang.Object def)
name.title
property. The message is fetched
from the name.message
property.comp
- The component to display the dialog forname
- The name of the dialogdef
- The text to display by default in the input fieldpublic static java.lang.String inputProperty(java.awt.Component comp, java.lang.String name, java.lang.String def)
name.title
property. The message is fetched
from the name.message
property.comp
- The component to display the dialog forname
- The name of the dialogdef
- The property whose text to display in the input fieldpublic static java.lang.String input(java.awt.Component comp, java.lang.String name, java.lang.Object[] args, java.lang.Object def)
name.title
property. The message is fetched
from the name.message
property.comp
- The component to display the dialog forname
- The name of the dialogdef
- The text to display by default in the input fieldargs
- Positional parameters to be substituted into the
message textpublic static java.lang.String inputProperty(java.awt.Component comp, java.lang.String name, java.lang.Object[] args, java.lang.String def)
name.title
property. The message is fetched
from the name.message
property.comp
- The component to display the dialog forname
- The name of the dialogargs
- Positional parameters to be substituted into the
message textdef
- The property whose text to display in the input fieldpublic static int confirm(java.awt.Component comp, java.lang.String name, java.lang.Object[] args, int buttons, int type)
name.title
property. The message is fetched
from the name.message
property.comp
- The component to display the dialog forname
- The name of the dialogargs
- Positional parameters to be substituted into the
message textbuttons
- The buttons to display - for example,
JOptionPane.YES_NO_CANCEL_OPTIONtype
- The dialog type - for example,
JOptionPane.WARNING_MESSAGEpublic static int option(java.awt.Component comp, java.lang.String name, java.lang.Object[] args, int type, java.lang.Object[] options, java.lang.Object initialValue)
name.title
property. The message is fetched
from the name.message
property.comp
- The component to display the dialog forname
- The name of the dialogargs
- Positional parameters to be substituted into the
message texttype
- The dialog type - for example,
JOptionPane.WARNING_MESSAGEoptions
- the buttonsinitialValue
- the initial valuepublic static int listConfirm(java.awt.Component comp, java.lang.String name, java.lang.String[] args, java.lang.Object[] listModel)
name.title
property. The message is fetched
from the name.message
property. The dialog
also shows a list of entries given by the listModel
parameter.comp
- the parent componentname
- the name of the confirm dialogargs
- the for the messagelistModel
- the items in the listpublic static int listConfirm(java.awt.Component comp, java.lang.String name, java.lang.String[] args, java.lang.Object[] listModel, java.util.List selectedItems)
name.title
property. The message is fetched
from the name.message
property. The dialog
also shows a list of entries given by the listModel
parameter.comp
- the parent componentname
- the name of the confirm dialogargs
- the for the messagelistModel
- the items in the listselectedItems
- give an empty list, it will contains in return the selected itemspublic static java.lang.String[] showVFSFileDialog(View view, java.lang.String path, int type, boolean multipleSelection)
view
- The view, should be non-nullpath
- The initial directory to display. May be nulltype
- The dialog type. One of
VFSBrowser.OPEN_DIALOG
,
VFSBrowser.SAVE_DIALOG
, or
VFSBrowser.CHOOSE_DIRECTORY_DIALOG
.multipleSelection
- True if multiple selection should be allowedpublic static java.lang.String[] showVFSFileDialog(java.awt.Dialog parent, View view, java.lang.String path, int type, boolean multipleSelection)
view
- The view, should be non-nullpath
- The initial directory to display. May be nulltype
- The dialog type. One of
VFSBrowser.OPEN_DIALOG
,
VFSBrowser.SAVE_DIALOG
, or
VFSBrowser.CHOOSE_DIRECTORY_DIALOG
.multipleSelection
- True if multiple selection should be allowedpublic static java.lang.String[] showVFSFileDialog(java.awt.Frame parent, View view, java.lang.String path, int type, boolean multipleSelection)
parent
- The parent frameview
- The view, should be non-nullpath
- The initial directory to display. May be nulltype
- The dialog type. One of
VFSBrowser.OPEN_DIALOG
,
VFSBrowser.SAVE_DIALOG
, or
VFSBrowser.CHOOSE_DIRECTORY_DIALOG
.multipleSelection
- True if multiple selection should be allowedpublic static java.awt.Font menuAcceleratorFont()
public static java.awt.Color parseColor(java.lang.String name)
SyntaxUtilities.parseColor(String, Color)
java.awt.Color
class) or a hex color value
prefixed with `#', for example `#ff0088'.name
- The color namepublic static SyntaxStyle parseStyle(java.lang.String str, java.lang.String family, int size) throws java.lang.IllegalArgumentException
SyntaxUtilities.parseStyle(String, String, int, boolean)
str
- The style stringfamily
- Style strings only specify font style, not font familysize
- Style strings only specify font style, not font familyjava.lang.IllegalArgumentException
- if the style is invalidpublic static java.lang.String getStyleString(SyntaxStyle style)
style
- The stylepublic static void loadGeometry(java.awt.Window win, java.awt.Container parent, java.lang.String name)
name.x
,
name.y
, name.width
and
name.height
properties.win
- The window to load geometry fromparent
- The parent frame to be relative to.name
- The name of the windowpublic static void loadGeometry(java.awt.Window win, java.lang.String name)
name.x
,
name.y
, name.width
and
name.height
properties.win
- The window to load geometry fromname
- The name of the windowpublic static void adjustForScreenBounds(java.awt.Rectangle desired)
GenericGUIUtilities.adjustForScreenBounds(Rectangle)
public static void saveGeometry(java.awt.Window win, java.lang.String name)
name.x
,
name.y
, name.width
and
name.height
properties.addSizeSaver(Frame,String)
to save the sizes
correct even if the Frame is in maximized or iconified state.win
- The window to load geometry fromname
- The name of the windowaddSizeSaver(Frame,String)
public static void saveGeometry(java.awt.Window win, java.awt.Container parent, java.lang.String name)
name.x
,
name.y
, name.width
and
name.height
properties.addSizeSaver(Frame,Container,String)
to save the sizes
correct even if the Frame is in maximized or iconified state.win
- The window to load geometry fromparent
- The parent frame to be relative to.name
- The name of the windowaddSizeSaver(Frame,Container,String)
public static void hideSplashScreen()
public static void applyTextAreaColors(java.awt.Container win)
public static javax.swing.JComponent createMultilineLabel(java.lang.String str)
JLabels
in
a JPanel
.str
- The string, with lines delimited by newline
(\n
) characters.public static void requestFocus(java.awt.Window win, java.awt.Component comp)
GenericGUIUtilities.requestFocus(Window, Component)
win
- The windowcomp
- The componentpublic static boolean isPopupTrigger(java.awt.event.MouseEvent evt)
GenericGUIUtilities.requestFocus(Window, Component)
evt
- The eventpublic static boolean isMiddleButton(int modifiers)
GenericGUIUtilities.isMiddleButton(int)
modifiers
- The modifiers flag from a mouse eventpublic static boolean isRightButton(int modifiers)
GenericGUIUtilities.isRightButton(int)
modifiers
- The modifiers flag from a mouse eventpublic static java.awt.Rectangle getScreenBounds()
GenericGUIUtilities.getScreenBounds()
public static void showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y)
popup
- The popup menucomp
- The component to show it forx
- The x co-ordinatey
- The y co-ordinatesetComponentPopupMenu
which works better and is simpler to use: you don't have to write the code to
show/hide popups in response to mouse events anymore.
public static void showPopupMenu(javax.swing.JPopupMenu popup, java.awt.Component comp, int x, int y, boolean point)
popup
- The popup menucomp
- The component to show it forx
- The x co-ordinatey
- The y co-ordinatepoint
- If true, then the popup originates from a single point;
otherwise it will originate from the component itself. This affects
positioning in the case where the popup does not fit onscreen.public static boolean isAncestorOf(java.awt.Component comp1, java.awt.Component comp2)
GenericGUIUtilities.isAncestorOf(Component, Component)
comp1
- The ancestorcomp2
- The component to checkpublic static javax.swing.JDialog getParentDialog(java.awt.Component c)
GenericGUIUtilities.getParentDialog(Component)
c
- The componentpublic static java.awt.Component getComponentParent(java.awt.Component comp, java.lang.Class clazz)
comp
- The componentclazz
- Looks for a parent with this class (exact match, not
derived).public static void setEnabledRecursively(java.awt.Container c, boolean enabled)
GenericGUIUtilities.setEnabledRecursively(Container, boolean)
c
- The containerenabled
- The enabled state to setpublic static View getView(java.awt.Component comp)
comp
- the component from which you want to get the parent viewpublic static void setButtonContentMargin(javax.swing.AbstractButton button, java.awt.Insets margin)
button
- the button to modifymargin
- the new marginpublic static void makeSameSize(java.awt.Component... components)
GenericGUIUtilities.makeSameSize(Component...)
components
- The components to make the same size.public static java.awt.Dimension defaultTableCellSize()
GenericGUIUtilities.defaultTableCellSize()
public static int defaultColumnWidth()
GenericGUIUtilities.defaultColumnWidth()
public static int defaultRowHeight()
GenericGUIUtilities.defaultRowHeight()
public static void addSizeSaver(java.awt.Frame frame, java.lang.String name)
saveGeometry(Window,String)
frame
- The Frame for which to save the sizename
- The prefix for the settingssaveGeometry(Window,String)
public static void addSizeSaver(java.awt.Frame frame, java.awt.Container parent, java.lang.String name)
saveGeometry(Window,Container,String)
frame
- The Frame for which to save the sizeparent
- The parent to be relative toname
- The prefix for the settingssaveGeometry(Window,Container,String)