| java.lang.Object org.gjt.sp.jedit.GUIUtilities
GUIUtilities | public class GUIUtilities (Code) | | Various GUI functions.
The most frequently used members of this class are:
-
GUIUtilities.loadIcon(String)
-
GUIUtilities.confirm(Component,String,Object[],int,int)
-
GUIUtilities.error(Component,String,Object[])
-
GUIUtilities.message(Component,String,Object[])
-
GUIUtilities.showVFSFileDialog(View,String,int,boolean)
-
GUIUtilities.loadGeometry(Window,String)
-
GUIUtilities.saveGeometry(Window,String)
-
GUIUtilities.showPopupMenu(JPopupMenu,Component,int,int)
author: Slava Pestov version: $Id: GUIUtilities.java 11177 2007-12-01 09:50:50Z k_satoda $ |
Inner Class :static class UnixWorkaround | |
Method Summary | |
public static void | addSizeSaver(Frame frame, String name) Adds a SizeSaver to the specified Frame. | public static void | addSizeSaver(Frame frame, Container parent, String name) Adds a SizeSaver to the specified Frame. | public static void | adjustForScreenBounds(Rectangle desired) Gives a rectangle the specified bounds, ensuring it is within the
screen bounds. | static void | advanceSplashProgress() | static void | advanceSplashProgress(String label) | public static void | centerOnScreen(Window win) Centers the given window on the screen. | public static int | confirm(Component comp, String name, Object[] args, int buttons, int type) Displays a confirm dialog box and returns the button pushed by the
user. | public static JComponent | createMultilineLabel(String str) Creates a component that displays a multiple line message. | public static void | error(Component comp, String name, Object[] args) Displays an error dialog box.
The title of the dialog is fetched from
the name.title property. | public static String | getColorHexString(Color c) Converts a color object to its hex value. | public static Component | getComponentParent(Component comp, Class clazz) Finds a parent of the specified component. | public static Image | getEditorIcon() Returns the default editor window image. | public static JDialog | getParentDialog(Component c) Traverses the given component's parent tree looking for an
instance of JDialog, and return it. | public static Image | getPluginIcon() Returns the default plugin window image. | public static String | getShortcutLabel(String action) Returns a label string to show users what shortcut are
assigned to the action. | public static String | getStyleString(SyntaxStyle style) Converts a style into it's string representation. | public static View | getView(Component comp) Finds the view parent of the specified component. | public static void | hideSplashScreen() Ensures that the splash screen is not visible. | static void | init() | public static void | initContinuousLayout(JSplitPane split) Init the continuous layout flag using the jEdit's property
appearance.continuousLayout
Parameters: split - the split. | public static String | input(Component comp, String name, Object def) Displays an input dialog box and returns any text the user entered.
The title of the dialog is fetched from
the name.title property. | public static String | input(Component comp, String name, Object[] args, Object def) Displays an input dialog box and returns any text the user entered.
The title of the dialog is fetched from
the name.title property. | public static String | inputProperty(Component comp, String name, String def) Displays an input dialog box and returns any text the user entered.
The title of the dialog is fetched from
the name.title property. | public static String | inputProperty(Component comp, String name, Object[] args, String def) Displays an input dialog box and returns any text the user entered.
The title of the dialog is fetched from
the name.title property. | public static boolean | isAncestorOf(Component comp1, Component comp2) Returns if the first component is an ancestor of the
second by traversing up the component hierarchy. | public static boolean | isMiddleButton(int modifiers) | public static boolean | isPopupTrigger(MouseEvent evt) Returns if the specified event is the popup trigger event. | public static boolean | isRightButton(int modifiers) | public static int | listConfirm(Component comp, String name, String[] args, Object[] listModel) Displays a confirm dialog box and returns the button pushed by the
user. | public static int | listConfirm(Component comp, String name, String[] args, Object[] listModel, List selectedItems) Displays a confirm dialog box and returns the button pushed by the
user. | public static void | loadGeometry(Window win, Container parent, String name) Loads a windows's geometry from the properties. | public static void | loadGeometry(Window win, String name) Loads a windows's geometry from the properties. | public static Icon | loadIcon(String iconName) Loads an icon. | public static JMenu | loadMenu(String name) Creates a menu. | public static JMenu | loadMenu(ActionContext context, String name) Creates a menu. | public static JMenuBar | loadMenuBar(String name) Creates a menubar. | public static JMenuBar | loadMenuBar(ActionContext context, String name) Creates a menubar. | public static JMenuItem | loadMenuItem(String name) Creates a menu item. | public static JMenuItem | loadMenuItem(String name, boolean setMnemonic) Creates a menu item. | public static JMenuItem | loadMenuItem(ActionContext context, String name, boolean setMnemonic) Creates a menu item. | public static JMenuItem | loadMenuItem(EditAction editAction, boolean setMnemonic) | public static JPopupMenu | loadPopupMenu(String name) Creates a popup menu. | public static JPopupMenu | loadPopupMenu(ActionContext context, String name) Creates a popup menu. | public static SyntaxStyle[] | loadStyles(String family, int size) Loads the syntax styles from the properties, giving them the specified
base font family and size. | public static SyntaxStyle[] | loadStyles(String family, int size, boolean color) Loads the syntax styles from the properties, giving them the specified
base font family and size. | public static Box | loadToolBar(String name) Creates a toolbar. | public static Box | loadToolBar(ActionContext context, String name) Creates a toolbar. | public static EnhancedButton | loadToolButton(String name) Loads a tool bar button. | public static EnhancedButton | loadToolButton(ActionContext context, String name) Loads a tool bar button. | public static void | message(Component comp, String name, Object[] args) Displays a dialog box.
The title of the dialog is fetched from
the name.title property. | public static Color | parseColor(String name) Converts a color name to a color object. | public static Color | parseColor(String name, Color defaultColor) | public static SyntaxStyle | parseStyle(String str, String family, int size) Converts a style string to a style object. | public static SyntaxStyle | parseStyle(String str, String family, int size, boolean color) Converts a style string to a style object. | public static String | prettifyMenuLabel(String label) `Prettifies' a menu item label by removing the `$' sign. | public static void | requestFocus(Window win, Component comp) Focuses on the specified component as soon as the window becomes
active. | public static void | saveGeometry(Window win, String name) Saves a window's geometry to the properties. | public static void | saveGeometry(Window win, Container parent, String name) Saves a window's geometry to the properties. | public static void | setIconPath(String iconPath) Sets the path where jEdit looks for icons. | public static void | showPopupMenu(JPopupMenu popup, Component comp, int x, int y) Shows the specified popup menu, ensuring it is displayed within
the bounds of the screen. | public static void | showPopupMenu(JPopupMenu popup, Component comp, int x, int y, boolean point) Shows the specified popup menu, ensuring it is displayed within
the bounds of the screen.
Parameters: popup - The popup menu Parameters: comp - The component to show it for Parameters: x - The x co-ordinate Parameters: y - The y co-ordinate Parameters: point - If true, then the popup originates from a single point;otherwise it will originate from the component itself. | static void | showSplashScreen() | public static String[] | showVFSFileDialog(View view, String path, int type, boolean multipleSelection) Displays a VFS file selection dialog box.
Parameters: view - The view, should be non-null Parameters: path - The initial directory to display. | public static String[] | showVFSFileDialog(Dialog parent, View view, String path, int type, boolean multipleSelection) Displays a VFS file selection dialog box.
This version can specify a dialog as the parent instead
of the view.
Parameters: view - The view, should be non-null Parameters: path - The initial directory to display. | public static String[] | showVFSFileDialog(Frame parent, View view, String path, int type, boolean multipleSelection) Displays a VFS file selection dialog box.
This version can specify a frame as the parent instead
of the view.
Parameters: parent - The parent frame Parameters: view - The view, should be non-null Parameters: path - The initial directory to display. |
DIRTY_BUFFER_ICON | public static Icon DIRTY_BUFFER_ICON(Code) | | |
NEW_BUFFER_ICON | public static Icon NEW_BUFFER_ICON(Code) | | |
NORMAL_BUFFER_ICON | public static Icon NORMAL_BUFFER_ICON(Code) | | |
READ_ONLY_BUFFER_ICON | public static Icon READ_ONLY_BUFFER_ICON(Code) | | |
adjustForScreenBounds | public static void adjustForScreenBounds(Rectangle desired)(Code) | | Gives a rectangle the specified bounds, ensuring it is within the
screen bounds.
since: jEdit 4.2pre3 |
advanceSplashProgress | static void advanceSplashProgress()(Code) | | |
advanceSplashProgress | static void advanceSplashProgress(String label)(Code) | | |
confirm | public static int confirm(Component comp, String name, Object[] args, int buttons, int type)(Code) | | Displays a confirm dialog box and returns the button pushed by the
user. The title of the dialog is fetched from the
name.title property. The message is fetched
from the name.message property.
Parameters: comp - The component to display the dialog for Parameters: name - The name of the dialog Parameters: args - Positional parameters to be substituted into themessage text Parameters: buttons - The buttons to display - for example,JOptionPane.YES_NO_CANCEL_OPTION Parameters: type - The dialog type - for example,JOptionPane.WARNING_MESSAGE since: jEdit 3.1pre3 |
createMultilineLabel | public static JComponent createMultilineLabel(String str)(Code) | | Creates a component that displays a multiple line message. This
is implemented by assembling a number of JLabels in
a JPanel .
Parameters: str - The string, with lines delimited by newline(\n ) characters. since: jEdit 4.1pre3 |
error | public static void error(Component comp, String name, Object[] args)(Code) | | Displays an error dialog box.
The title of the dialog is fetched from
the 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.
Parameters: comp - The component to display the dialog for Parameters: name - The name of the dialog Parameters: args - Positional parameters to be substituted into themessage text |
getColorHexString | public static String getColorHexString(Color c)(Code) | | Converts a color object to its hex value. The hex value
prefixed is with `#', for example `#ff0088'.
Parameters: c - The color object |
getComponentParent | public static Component getComponentParent(Component comp, Class clazz)(Code) | | Finds a parent of the specified component.
Parameters: comp - The component Parameters: clazz - Looks for a parent with this class (exact match, notderived). since: jEdit 4.2pre1 |
getEditorIcon | public static Image getEditorIcon()(Code) | | Returns the default editor window image.
|
getParentDialog | public static JDialog getParentDialog(Component c)(Code) | | Traverses the given component's parent tree looking for an
instance of JDialog, and return it. If not found, return null.
Parameters: c - The component |
getPluginIcon | public static Image getPluginIcon()(Code) | | Returns the default plugin window image.
|
getShortcutLabel | public static String getShortcutLabel(String action)(Code) | | Returns a label string to show users what shortcut are
assigned to the action.
|
getStyleString | public static String getStyleString(SyntaxStyle style)(Code) | | Converts a style into it's string representation.
Parameters: style - The style |
getView | public static View getView(Component comp)(Code) | | Finds the view parent of the specified component.
since: jEdit 4.0pre2 |
hideSplashScreen | public static void hideSplashScreen()(Code) | | Ensures that the splash screen is not visible. This should be
called before displaying any dialog boxes or windows at
startup.
|
initContinuousLayout | public static void initContinuousLayout(JSplitPane split)(Code) | | Init the continuous layout flag using the jEdit's property
appearance.continuousLayout
Parameters: split - the split. It must never be null since: jEdit 4.3pre9 |
input | public static String input(Component comp, String name, Object def)(Code) | | Displays an input dialog box and returns any text the user entered.
The title of the dialog is fetched from
the name.title property. The message is fetched
from the name.message property.
Parameters: comp - The component to display the dialog for Parameters: name - The name of the dialog Parameters: def - The text to display by default in the input field |
input | public static String input(Component comp, String name, Object[] args, Object def)(Code) | | Displays an input dialog box and returns any text the user entered.
The title of the dialog is fetched from
the name.title property. The message is fetched
from the name.message property.
Parameters: comp - The component to display the dialog for Parameters: name - The name of the dialog Parameters: def - The text to display by default in the input field Parameters: args - Positional parameters to be substituted into themessage text since: jEdit 3.1pre3 |
inputProperty | public static String inputProperty(Component comp, String name, String def)(Code) | | Displays an input dialog box and returns any text the user entered.
The title of the dialog is fetched from
the name.title property. The message is fetched
from the name.message property.
Parameters: comp - The component to display the dialog for Parameters: name - The name of the dialog Parameters: def - The property whose text to display in the input field |
inputProperty | public static String inputProperty(Component comp, String name, Object[] args, String def)(Code) | | Displays an input dialog box and returns any text the user entered.
The title of the dialog is fetched from
the name.title property. The message is fetched
from the name.message property.
Parameters: comp - The component to display the dialog for Parameters: name - The name of the dialog Parameters: args - Positional parameters to be substituted into themessage text Parameters: def - The property whose text to display in the input field since: jEdit 3.1pre3 |
isAncestorOf | public static boolean isAncestorOf(Component comp1, Component comp2)(Code) | | Returns if the first component is an ancestor of the
second by traversing up the component hierarchy.
Parameters: comp1 - The ancestor Parameters: comp2 - The component to check since: jEdit 4.1pre5 |
isMiddleButton | public static boolean isMiddleButton(int modifiers)(Code) | | Parameters: modifiers - The modifiers flag from a mouse event since: jEdit 4.1pre9 |
isPopupTrigger | public static boolean isPopupTrigger(MouseEvent evt)(Code) | | Returns if the specified event is the popup trigger event.
This implements precisely defined behavior, as opposed to
MouseEvent.isPopupTrigger().
Parameters: evt - The event since: jEdit 3.2pre8 |
isRightButton | public static boolean isRightButton(int modifiers)(Code) | | Parameters: modifiers - The modifiers flag from a mouse event since: jEdit 4.1pre9 |
listConfirm | public static int listConfirm(Component comp, String name, String[] args, Object[] listModel)(Code) | | Displays a confirm dialog box and returns the button pushed by the
user. The title of the dialog is fetched from the
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.
Parameters: comp - the parent component Parameters: name - the name of the confirm dialog Parameters: args - the for the message Parameters: listModel - the items in the list an integer indicating the option selected by the user since: jEdit 4.3pre1 |
listConfirm | public static int listConfirm(Component comp, String name, String[] args, Object[] listModel, List selectedItems)(Code) | | Displays a confirm dialog box and returns the button pushed by the
user. The title of the dialog is fetched from the
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.
Parameters: comp - the parent component Parameters: name - the name of the confirm dialog Parameters: args - the for the message Parameters: listModel - the items in the list Parameters: selectedItems - give an empty list, it will contains in return the selected items an integer indicating the option selected by the user since: jEdit 4.3pre12 |
loadGeometry | public static void loadGeometry(Window win, Container parent, String name)(Code) | | Loads a windows's geometry from the properties.
The geometry is loaded from the name.x ,
name.y , name.width and
name.height properties.
Parameters: win - The window to load geometry from Parameters: parent - The parent frame to be relative to. Parameters: name - The name of the window |
loadGeometry | public static void loadGeometry(Window win, String name)(Code) | | Loads a windows's geometry from the properties.
The geometry is loaded from the name.x ,
name.y , name.width and
name.height properties.
Parameters: win - The window to load geometry from Parameters: name - The name of the window |
loadIcon | public static Icon loadIcon(String iconName)(Code) | | Loads an icon.
Parameters: iconName - The icon name since: jEdit 2.6pre7 |
loadMenu | public static JMenu loadMenu(String name)(Code) | | Creates a menu. The menu label is set from the
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.
Parameters: name - The menu name See Also: GUIUtilities.loadMenuItem(String) since: jEdit 2.6pre2 |
loadMenu | public static JMenu loadMenu(ActionContext context, String name)(Code) | | Creates a menu. The menu label is set from the
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.
Parameters: context - An action context; eitherjEdit.getActionContext() orVFSBrowser.getActionContext() . Parameters: name - The menu name See Also: GUIUtilities.loadMenuItem(String) since: jEdit 4.2pre1 |
loadMenuBar | public static JMenuBar loadMenuBar(String name)(Code) | | Creates a menubar. Plugins should not need to call this method.
Parameters: name - The menu bar name since: jEdit 3.2pre5 |
loadMenuBar | public static JMenuBar loadMenuBar(ActionContext context, String name)(Code) | | Creates a menubar. Plugins should not need to call this method.
Parameters: context - An action context Parameters: name - The menu bar name since: jEdit 4.2pre1 |
loadMenuItem | public static JMenuItem loadMenuItem(String name, boolean setMnemonic)(Code) | | Creates a menu item.
Parameters: name - The menu item name Parameters: setMnemonic - True if the menu item should have a mnemonic since: jEdit 3.1pre1 |
loadMenuItem | public static JMenuItem loadMenuItem(ActionContext context, String name, boolean setMnemonic)(Code) | | Creates a menu item.
Parameters: context - An action context; eitherjEdit.getActionContext() orVFSBrowser.getActionContext() . Parameters: name - The menu item name Parameters: setMnemonic - True if the menu item should have a mnemonic since: jEdit 4.2pre1 |
loadPopupMenu | public static JPopupMenu loadPopupMenu(String name)(Code) | | Creates a popup menu.
Parameters: name - The menu name since: jEdit 2.6pre2 |
loadPopupMenu | public static JPopupMenu loadPopupMenu(ActionContext context, String name)(Code) | | Creates a popup menu.
Parameters: context - An action context; eitherjEdit.getActionContext() orVFSBrowser.getActionContext() . Parameters: name - The menu name since: jEdit 4.2pre1 |
loadStyles | public static SyntaxStyle[] loadStyles(String family, int size)(Code) | | Loads the syntax styles from the properties, giving them the specified
base font family and size.
Parameters: family - The font family Parameters: size - The font size since: jEdit 3.2pre6 |
loadStyles | public static SyntaxStyle[] loadStyles(String family, int size, boolean color)(Code) | | Loads the syntax styles from the properties, giving them the specified
base font family and size.
Parameters: family - The font family Parameters: size - The font size Parameters: color - If false, the styles will be monochrome since: jEdit 4.0pre4 |
loadToolBar | public static Box loadToolBar(String name)(Code) | | Creates a toolbar.
Parameters: name - The toolbar name since: jEdit 4.2pre2 |
loadToolBar | public static Box loadToolBar(ActionContext context, String name)(Code) | | Creates a toolbar.
Parameters: context - An action context; eitherjEdit.getActionContext() orVFSBrowser.getActionContext() . Parameters: name - The toolbar name since: jEdit 4.2pre2 |
loadToolButton | public static EnhancedButton loadToolButton(String name)(Code) | | Loads a tool bar button. The tooltip is constructed from
the 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.
Parameters: name - The name of the button |
loadToolButton | public static EnhancedButton loadToolButton(ActionContext context, String name)(Code) | | Loads a tool bar button. The tooltip is constructed from
the 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.
Parameters: context - An action context; eitherjEdit.getActionContext() orVFSBrowser.getActionContext() . Parameters: name - The name of the button since: jEdit 4.2pre1 |
message | public static void message(Component comp, String name, Object[] args)(Code) | | Displays a dialog box.
The title of the dialog is fetched from
the 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.
Parameters: comp - The component to display the dialog for Parameters: name - The name of the dialog Parameters: args - Positional parameters to be substituted into themessage text |
parseColor | public static Color parseColor(String name)(Code) | | Converts a color name to a color object. The name must either be
a known string, such as `red', `green', etc (complete list is in
the java.awt.Color class) or a hex color value
prefixed with `#', for example `#ff0088'.
Parameters: name - The color name |
parseStyle | public static SyntaxStyle parseStyle(String str, String family, int size) throws IllegalArgumentException(Code) | | Converts a style string to a style object.
Parameters: str - The style string Parameters: family - Style strings only specify font style, not font family Parameters: size - Style strings only specify font style, not font family exception: IllegalArgumentException - if the style is invalid since: jEdit 3.2pre6 |
parseStyle | public static SyntaxStyle parseStyle(String str, String family, int size, boolean color) throws IllegalArgumentException(Code) | | Converts a style string to a style object.
Parameters: str - The style string Parameters: family - Style strings only specify font style, not font family Parameters: size - Style strings only specify font style, not font family Parameters: color - If false, the styles will be monochrome exception: IllegalArgumentException - if the style is invalid since: jEdit 4.0pre4 |
prettifyMenuLabel | public static String prettifyMenuLabel(String label)(Code) | | `Prettifies' a menu item label by removing the `$' sign. This
can be used to process the contents of an action.label
property.
|
requestFocus | public static void requestFocus(Window win, Component comp)(Code) | | Focuses on the specified component as soon as the window becomes
active.
Parameters: win - The window Parameters: comp - The component |
saveGeometry | public static void saveGeometry(Window win, String name)(Code) | | Saves a window's geometry to the properties.
The geometry is saved to the name.x ,
name.y , name.width and
name.height properties.
For Frame's and descendents use
GUIUtilities.addSizeSaver(Frame,String) to save the sizes
correct even if the Frame is in maximized or iconified state.
Parameters: win - The window to load geometry from Parameters: name - The name of the window See Also: GUIUtilities.addSizeSaver(Frame,String) |
setIconPath | public static void setIconPath(String iconPath)(Code) | | Sets the path where jEdit looks for icons.
since: jEdit 4.2pre5 |
showPopupMenu | public static void showPopupMenu(JPopupMenu popup, Component comp, int x, int y)(Code) | | Shows the specified popup menu, ensuring it is displayed within
the bounds of the screen.
Parameters: popup - The popup menu Parameters: comp - The component to show it for Parameters: x - The x co-ordinate Parameters: y - The y co-ordinate since: jEdit 4.0pre1 See Also: javax.swing.JComponent.setComponentPopupMenu(javax.swing.JPopupMenu) See Also: , See Also: which works better and is simpler to use: you don't have to write the code to See Also: show/hide popups in response to mouse events anymore. |
showPopupMenu | public static void showPopupMenu(JPopupMenu popup, Component comp, int x, int y, boolean point)(Code) | | Shows the specified popup menu, ensuring it is displayed within
the bounds of the screen.
Parameters: popup - The popup menu Parameters: comp - The component to show it for Parameters: x - The x co-ordinate Parameters: y - The y co-ordinate Parameters: point - If true, then the popup originates from a single point;otherwise it will originate from the component itself. This affectspositioning in the case where the popup does not fit onscreen. since: jEdit 4.1pre1 |
showSplashScreen | static void showSplashScreen()(Code) | | |
|
|