|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object biz.chitec.quarterback.swing.QSwingUtilities
Collection of helper methods for certain more complex Swing/GUI-based tasks.
Nested Class Summary | |
private static class |
QSwingUtilities.StandardStreamLogger
Internal helper class for log frame implementation. |
Field Summary | |
private static java.io.PrintStream |
oldstderr
|
private static java.io.PrintStream |
oldstdout
|
private static java.util.ResourceBundle |
rb
|
Constructor Summary | |
private |
QSwingUtilities()
Fully-static object. |
Method Summary | |
static void |
addLabelAndElementToPanel(java.awt.Container p,
java.util.ResourceBundle rb,
java.lang.String labelname,
java.awt.Component elem,
java.lang.Object constraint1,
java.lang.Object constraint2)
Adds an element together with a referring label into a container. |
static void |
addLabelAndElementToPanel(java.awt.Container p,
java.util.ResourceBundle rb,
java.lang.String labelname,
java.awt.Component elem,
java.lang.Object constraint1,
java.lang.Object constraint2,
boolean linklabel)
Adds an element together with a label into a container. |
static void |
addLabelAndElementToPanel(java.awt.Container p,
java.lang.String labelname,
java.awt.Component elem,
java.lang.Object constraint1,
java.lang.Object constraint2)
Adds an element together with a referring label into a container. |
static void |
addShownCA(java.awt.Component outerc,
java.awt.Component innerc)
Adds a ComponentListener to outerc so that innerc is hidden and shownin sync with outerc. |
static void |
adjustFrameOf(java.awt.Component c,
java.awt.Dimension tobeadded,
boolean hard)
Ensures that the frame containing c is at least big enough to contain all children. |
static void |
adjustTabbedPaneSelection(javax.swing.JTabbedPane jtp)
Checks and realigns the currently selected tab of a tabbed pane against the enabled states of the tabs. |
static void |
assertEventDispatchingThread()
Tests whether called in event dispatching thread. |
static void |
centerInternalFrame(javax.swing.JInternalFrame jif)
Centers a JInternalFrame within its JDesktopPane. |
static javax.swing.Box |
createDefaultHorizontalBox(int defaultstrut,
int horizontalmargins,
java.awt.Component[] components)
Returns a horizontal box containing all given components centered and with the same distance. |
static void |
disposeFrameOf(java.awt.Component c)
Disposes the Window/Frame, JFrame, or JInternalFrame object which contains the given Component |
static javax.swing.JFrame |
frameFor(java.awt.Container c)
Puts the given Component in an unlabelled JFrame. |
static javax.swing.JFrame |
frameFor(java.awt.Container c,
java.lang.String name)
Puts the given Container into a JFrame and installs a pass-through for component-shown events. |
static java.awt.Component |
getButtonForLabel(java.awt.Container container,
java.lang.String labeltext)
Returns the first button with the given text. |
static java.awt.Component |
getComponentForLabel(java.awt.Container container,
java.lang.String labeltext)
Returns the first component which is connected to a label with the given text. |
static java.awt.Component |
getComponentForTab(java.awt.Container container,
java.lang.String labeltext)
Returns the first component which is in a JTabbedPane under a tab with the given label. |
static java.awt.Container |
getFrameOf(java.awt.Component c)
Return the frame object containing the given component. |
static java.lang.String |
getHelpID(java.awt.Component c)
Returns the next available help id starting from the given component (usually the one with the focus). |
static java.awt.Frame |
getOutermostFrameOf(java.awt.Component c)
Return "real" frame, even for components put into internal frames. |
private static java.util.ResourceBundle |
getRB()
Helper method for loading the internally used resource bundle object |
static javax.swing.JInternalFrame |
internalFrameFor(java.awt.Container c)
Puts the given Component in an unlabelled JInternalFrame. |
static javax.swing.JInternalFrame |
internalFrameFor(java.awt.Container c,
java.util.ResourceBundle rb,
java.lang.String resname)
Puts the given Container into a JInternalFrame and installs a pass-through for component-shown events. |
static javax.swing.JInternalFrame |
internalFrameFor(java.awt.Container c,
java.lang.String name)
Deprecated. You should use the ResourceBundle'd version of this method |
static void |
loadSizeFromProperty(java.awt.Component theframe,
java.util.Properties props,
java.lang.String key,
java.awt.Rectangle alternative)
Load the shape of a component (mainly a frame or an internal frame) from a properties file. |
static void |
openStandardLogFrame()
Opens an independant JFrame showing all output from standard output and standard error streams. |
static void |
showCenteredPopupMenu(java.awt.Component invoker,
javax.swing.JPopupMenu popupmenu)
Places a popup menu centered to its invoker. |
static void |
showTabForLabel(java.awt.Container container,
java.lang.String labeltext)
Shows the first tab in the first JTabbedPane which has the given label text. |
static void |
showWindow(java.awt.Window win)
Places a window centered to its owner and shows it on screen. |
static void |
storeSizeToProperty(java.awt.Component theframe,
java.util.Properties props,
java.lang.String key)
Store the shape of a component (mainly a frame or an internal frame) into a properties file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static java.io.PrintStream oldstdout
private static java.io.PrintStream oldstderr
private static java.util.ResourceBundle rb
Constructor Detail |
private QSwingUtilities()
Method Detail |
private static java.util.ResourceBundle getRB()
public static java.awt.Container getFrameOf(java.awt.Component c)
c
- A widget component of the GUI
public static java.awt.Frame getOutermostFrameOf(java.awt.Component c)
c
- A widget component of the GUI
public static void adjustFrameOf(java.awt.Component c, java.awt.Dimension tobeadded, boolean hard)
c
- A component in the frame to be resizedtobeadded
- Additional space to be added or removed before size checkhard
- If true, just pack()public static void disposeFrameOf(java.awt.Component c)
public static void addShownCA(java.awt.Component outerc, java.awt.Component innerc)
public static javax.swing.JFrame frameFor(java.awt.Container c, java.lang.String name)
c
- The Container to be put into the JFramename
- JFrame's title
public static javax.swing.JFrame frameFor(java.awt.Container c)
public static javax.swing.JInternalFrame internalFrameFor(java.awt.Container c, java.lang.String name)
c
- The Container to be put into the JFramename
- JFrame's title
public static javax.swing.JInternalFrame internalFrameFor(java.awt.Container c, java.util.ResourceBundle rb, java.lang.String resname)
c
- The Container to be put into the JFramerb
- The ResourceBundle to read title and icon file name fromresname
- The name of the resource with the title and the iconfile name
public static javax.swing.JInternalFrame internalFrameFor(java.awt.Container c)
public static void adjustTabbedPaneSelection(javax.swing.JTabbedPane jtp)
If the currently selected tab is disabled, the next tab is selected. This is repeated until an enabled tab has been found or all tabs have been tried. In the later case, the original tab stays selected.
jtp
- The JTabbedPane to adjustpublic static javax.swing.Box createDefaultHorizontalBox(int defaultstrut, int horizontalmargins, java.awt.Component[] components)
defaultstrut
- Distance between the components in pixelshorizontalmargins
- Free space above and below the components in pixelscomponents
- Components to arrange in the Box
public static void addLabelAndElementToPanel(java.awt.Container p, java.util.ResourceBundle rb, java.lang.String labelname, java.awt.Component elem, java.lang.Object constraint1, java.lang.Object constraint2, boolean linklabel)
The label is added first, where the given ResourceBundle and String is taken to obtain the label's content. It is added with constraint1. Then, the element itself is added using constraint2. The label can be bound to the element to make it shortcuttable.
p
- The Container to put everything inrb
- ResourceBundle with the label's contentlabelname
- Name of the labelelem
- The element to put into the Containerconstraint1
- Layout constraints for the labelconstraint2
- Layout constraints for the elementlinklabel
- Flag whether the label should be linked to the element, important for hotkeyingpublic static void addLabelAndElementToPanel(java.awt.Container p, java.util.ResourceBundle rb, java.lang.String labelname, java.awt.Component elem, java.lang.Object constraint1, java.lang.Object constraint2)
p
- The Container to put everything inrb
- ResourceBundle with the label's contentlabelname
- Name of the labelelem
- The element to put into the Containerconstraint1
- Layout constraints for the labelconstraint2
- Layout constraints for the elementpublic static void addLabelAndElementToPanel(java.awt.Container p, java.lang.String labelname, java.awt.Component elem, java.lang.Object constraint1, java.lang.Object constraint2)
The label is added first, it is assumed to be correctly i18n'd. It is added with constraint1. Then, the element itself is added using constraint2. The label is bound to the element, so a shortcut can be given.
p
- The Container to put everything inlabelname
- I18N-aware name of the labelelem
- The element to put into the Containerconstraint1
- Layout constraints for the labelconstraint2
- Layout constraints for the elementpublic static void showWindow(java.awt.Window win)
This method is thread-safe. If it is not called from the event dispatching thread, it redispatched itself automatically into that thread. This means that, in this case, showing of the window on screen is done asynchronously to the caller.
win
- The window to be shown.public static void showCenteredPopupMenu(java.awt.Component invoker, javax.swing.JPopupMenu popupmenu)
invoker
- Invoker of the popup menupopupmenu
- The popup menu to showpublic static java.lang.String getHelpID(java.awt.Component c)
TOM
does it. The method traverses the
component tree upward until either a help id is found or the top-level window has been reached.
c
- Component Any component to start search from
public static void centerInternalFrame(javax.swing.JInternalFrame jif)
jif
- The JInternalFramepublic static void loadSizeFromProperty(java.awt.Component theframe, java.util.Properties props, java.lang.String key, java.awt.Rectangle alternative)
theframe
- Frame to set the shape ofprops
- Properties file to read the data fromkey
- Name under which the data is storedalternative
- Shape to set the frame to if no data can be found in the properties filepublic static void storeSizeToProperty(java.awt.Component theframe, java.util.Properties props, java.lang.String key)
theframe
- Frame to store the shape from.props
- Properties file to store the shape information into.key
- Key under which the properties information is stored.public static void assertEventDispatchingThread()
public static java.awt.Component getComponentForLabel(java.awt.Container container, java.lang.String labeltext)
If the component after the label is a non-empty Container itself (e.g. a JPanel), its first subcomponent is returned.
container
- The container to search inlabeltext
- Text on the label
public static java.awt.Component getButtonForLabel(java.awt.Container container, java.lang.String labeltext)
container
- The container to search inlabeltext
- Text on the Button
public static void showTabForLabel(java.awt.Container container, java.lang.String labeltext)
container
- A container to search in for JTabbedPanes. Not the JTabbedPane itself!labeltext
- Text to find on a label.public static java.awt.Component getComponentForTab(java.awt.Container container, java.lang.String labeltext)
If the component after the label is a non-empty Container itself (e.g. a JPanel), its first subcomponent is returned.
container
- A container to search in for JTabbedPanes. Not the JTabbedPane itself!labeltext
- Text to find on a label.
public static void openStandardLogFrame()
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |