Package chemaxon.marvin.util
Class SwingUtil
java.lang.Object
chemaxon.marvin.util.SwingUtil
- All Implemented Interfaces:
Serializable
Swing utility functions.
- Since:
- Marvin 3.3.1, 01/15/2004
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addHyperlinkListener
(JEditorPane editorPane) Adds HTML link handling to an editor pane.static JMenu
createMenu
(ResourceBundle rc, String key) Utility method to create a menu with a label specified as a resource.static JMenu
createMenu
(ResourceBundle rc, String key, boolean mnemo) Creates a menu with a label specified as a resource.static JMenuItem
createMenuItem
(ResourceBundle rc, String key) Creates a menu with a label specified as a resource.static JMenuItem
createMenuItem
(ResourceBundle rc, String key, boolean mnemo) Creates a menu with a label specified as a resource.static JMenuItem
createMenuItem
(ResourceBundle rc, String key, Class<?> what, boolean mnemo) Creates a menu item with a label specified as a resource.static JEditorPane
createMessagePane
(String text) Creates a message pane with HTML text content.static JPanel
createSubPanel
(String title) Creates a sub-panel with a title.static GridBagConstraints
Creates GridBagConstraints for the top left component.static void
decorateSubPanel
(JPanel panel, String title) Creates border and title for a panel.static KeyStroke
getCommandKeyStroke
(int key) Gets the command keystroke preferred on the current platform.static void
initAction
(Action action, ResourceBundle rc, String key, KeyStroke accel) Initializes an action from information in a resource.static void
initButton
(AbstractButton b, ResourceBundle rc, String key) Utility method to initialize a button from information in a resource.static void
initButton
(AbstractButton b, ResourceBundle rc, String key, boolean mnemo) Utility method to initialize a button from information in a resource.static void
Deprecated, for removal: This API element is subject to removal in a future version.does nothing.static void
Deprecated, for removal: This API element is subject to removal in a future version.does nothing.static <T> T
invokeAndWait
(Callable<T> callable) Calls SwingUtilities.invokeLater() for a Callable by wrapping it into a FutureTask object, blocks until it is finished and returns the result (calling FutureTask.get()).static <T> FutureTask<T>
invokeLater
(Callable<T> callable) Calls SwingUtilities.invokeLater() for a Callable by wrapping it into a FutureTask object.static void
setDefaultFont
(JEditorPane editorPane) Sets the SWING default font in the JEditorPane.
-
Constructor Details
-
SwingUtil
public SwingUtil()
-
-
Method Details
-
initInApplet
Deprecated, for removal: This API element is subject to removal in a future version.does nothing. -
getCommandKeyStroke
Gets the command keystroke preferred on the current platform. Ctrl+key on Linux and Windows, Command+key on Mac.- Parameters:
key
- the key- Returns:
- keystroke for the specified key and meta (for Mac) or control (for other platforms)
-
createMenuItem
Creates a menu item with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
rc
- the resourceskey
- name of the label resourcewhat
- menu item classmnemo
- use mnemonic or not- Returns:
- the menu
- Since:
- Marvin 4.1, 11/10/2005
-
createMenuItem
Creates a menu with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
rc
- the resourceskey
- name of the label resourcemnemo
- set the mnemonic or not- Returns:
- the menu item
- Since:
- Marvin 4.1, 11/10/2005
-
createMenuItem
Creates a menu with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
rc
- the resourceskey
- name of the label resource- Returns:
- the menu item
- Since:
- Marvin 4.1, 11/10/2005
-
createMenu
Utility method to create a menu with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
rc
- the resourceskey
- name of the label resource- Returns:
- the menu
-
createMenu
Creates a menu with a label specified as a resource. If the label string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
rc
- the resourceskey
- name of the label resourcemnemo
- set the mnemonic or not- Returns:
- the menu
- Since:
- Marvin 4.1, 11/10/2005
-
initButton
Utility method to initialize a button from information in a resource. If the resource string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
b
- the buttonrc
- the resourceskey
- name of the resource
-
initButton
Utility method to initialize a button from information in a resource. If the resource string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
b
- the buttonrc
- the resourceskey
- name of the resourcemnemo
- set the mnemonic or not
-
initAction
Initializes an action from information in a resource. If the resource string is of the form "'x'label", then x will be the mnemonic character and the actual label will be label.- Parameters:
action
- the actionrc
- the resourceskey
- name of the resourceaccel
- the accelerator or null
-
initCtrlShortcutForMac
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public static void initCtrlShortcutForMac(JMenuItem mi) Deprecated, for removal: This API element is subject to removal in a future version.does nothing. -
decorateSubPanel
Creates border and title for a panel.- Parameters:
title
- the panel title- Since:
- Marvin 4.1, 11/10/2005
-
createSubPanel
Creates a sub-panel with a title.- Parameters:
title
- the panel title- Returns:
- the panel
- Since:
- Marvin 4.1, 11/10/2005
- See Also:
-
createTopLeftConstraints
Creates GridBagConstraints for the top left component.- Returns:
- the constraints
- Since:
- Marvin 4.1, 11/10/2005
-
createMessagePane
Creates a message pane with HTML text content. HTML links are handled, referred pages are displayed in the default browser.- Parameters:
text
- the content, may contain HTML links- Returns:
- the message pane
-
setDefaultFont
Sets the SWING default font in the JEditorPane. This is necessary because originally the font is read from a style sheet. This method adds a CSS rule to force body tags to use the default label font instead of the value in javax.swing.text.html.default.css. Code is copied from: http://explodingpixels.wordpress.com/2008/10/28/make-jeditorpane-use-the-system-font/- Parameters:
editorPane
- the JEditorPane
-
addHyperlinkListener
Adds HTML link handling to an editor pane. The referred content will be displayed in the default browser.- Parameters:
editorPane
- the JEditorPane
-
invokeLater
Calls SwingUtilities.invokeLater() for a Callable by wrapping it into a FutureTask object. Written by Karl Schaefer. Source: http://weblogs.java.net/blog/kschaefe/archive/2010/11/15/returns-values-swingutilitiesinvoke- Parameters:
callable
- the Callable object to be invoked on the event dispatch thread- Returns:
- the wrapper FutureTask
-
invokeAndWait
public static <T> T invokeAndWait(Callable<T> callable) throws InterruptedException, InvocationTargetException Calls SwingUtilities.invokeLater() for a Callable by wrapping it into a FutureTask object, blocks until it is finished and returns the result (calling FutureTask.get()). Written by Karl Schaefer. Source: http://weblogs.java.net/blog/kschaefe/archive/2010/11/15/returns-values-swingutilitiesinvoke- Parameters:
callable
- the Callable object to be invoked on the event dispatch thread- Returns:
- the return value of the callable returned in FutureTask.get()
- Throws:
InterruptedException
InvocationTargetException
-