org.springframework.richclient.util
Class GuiStandardUtils

java.lang.Object
  extended by org.springframework.richclient.util.GuiStandardUtils

public class GuiStandardUtils
extends Object

Utility functions that help enforce a standard look and feel in accordance with the Java Look and Feel Design Guidelines.

Author:
Keith Donald

Method Summary
static JComponent attachBorder(JComponent c)
           
static JComponent attachBorder(JComponent c, Border border)
           
static JComponent attachDialogBorder(JComponent c)
           
static JTextArea configureStandardTextArea(JTextArea textArea)
           
static JComponent createCommandButtonColumn(JButton[] buttons)
          Make a vertical row of buttons of equal size, whch are equally spaced, and aligned on the right.
static JComponent createCommandButtonRow(JButton[] buttons)
          Make a horizontal row of buttons of equal size, whch are equally spaced, and aligned on the right.
static void createDebugBorder(JComponent c, Color color)
          Useful debug function to place a colored, line border around a component for layout management debugging.
static String createDialogTitle(String appName, String dialogName)
          Return text which conforms to the Look and Feel Design Guidelines for the title of a dialog : the application name, a colon, then the name of the specific dialog.
static Border createEvenlySpacedBorder(com.jgoodies.forms.layout.ConstantSize space)
           
static Border createEvenlySpacedBorder(int spacePx)
           
static Border createLeftAndRightBorder(com.jgoodies.forms.layout.ConstantSize space)
           
static Border createLeftAndRightBorder(int spacePx)
           
static JTextArea createStandardTextArea(int rows, int columns)
           
static JTextArea createStandardTextArea(String text)
          An alternative to multi-line labels, for the presentation of several lines of text, and for which the line breaks are determined solely by the control.
static JTextArea createStandardTextAreaHardNewLines(String text)
          An alternative to multi-line labels, for the presentation of several lines of text, and for which line breaks are determined solely by aText, and not by the control.
static Border createTopAndBottomBorder(com.jgoodies.forms.layout.ConstantSize space)
           
static Border createTopAndBottomBorder(int spacePx)
           
static void equalizeSizes(JComponent[] components)
          Sets the items in aComponents to the same size.
static Border getStandardDialogBorder()
           
static JTextArea textAreaAsLabel(JTextArea textArea)
          This will allow selection and copy to work but still retain the label look
static JTextComponent textComponentAsLabel(JTextComponent textcomponent)
          This will allow selection and copy to work but still retain the label look
static void truncateLabelIfLong(JLabel label)
          If aLabel has text which is longer than MAX_LABEL_LENGTH, then truncate the label text and place an ellipsis at the end; the original text is placed in a tooltip.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

attachBorder

public static JComponent attachBorder(JComponent c,
                                      Border border)

attachBorder

public static JComponent attachBorder(JComponent c)

attachDialogBorder

public static JComponent attachDialogBorder(JComponent c)

getStandardDialogBorder

public static Border getStandardDialogBorder()

createEvenlySpacedBorder

public static Border createEvenlySpacedBorder(int spacePx)

createEvenlySpacedBorder

public static Border createEvenlySpacedBorder(com.jgoodies.forms.layout.ConstantSize space)

createLeftAndRightBorder

public static Border createLeftAndRightBorder(int spacePx)

createLeftAndRightBorder

public static Border createLeftAndRightBorder(com.jgoodies.forms.layout.ConstantSize space)

createTopAndBottomBorder

public static Border createTopAndBottomBorder(int spacePx)

createTopAndBottomBorder

public static Border createTopAndBottomBorder(com.jgoodies.forms.layout.ConstantSize space)

createDialogTitle

public static String createDialogTitle(String appName,
                                       String dialogName)
Return text which conforms to the Look and Feel Design Guidelines for the title of a dialog : the application name, a colon, then the name of the specific dialog.

Parameters:
dialogName - the short name of the dialog.

createCommandButtonRow

public static JComponent createCommandButtonRow(JButton[] buttons)
Make a horizontal row of buttons of equal size, whch are equally spaced, and aligned on the right.

The returned component has border spacing only on the top (of the size recommended by the Look and Feel Design Guidelines). All other spacing must be applied elsewhere ; usually, this will only mean that the dialog's top-level panel should use #buildStandardBorder.

Parameters:
buttons - contains JButton objects.
Returns:
A row displaying the buttons horizontally.

createCommandButtonColumn

public static JComponent createCommandButtonColumn(JButton[] buttons)
Make a vertical row of buttons of equal size, whch are equally spaced, and aligned on the right.

The returned component has border spacing only on the left (of the size recommended by the Look and Feel Design Guidelines). All other spacing must be applied elsewhere ; usually, this will only mean that the dialog's top-level panel should use #buildStandardBorder.

Parameters:
buttons - contains JButton objects.
Returns:
A column displaying the buttons vertically.

equalizeSizes

public static void equalizeSizes(JComponent[] components)
Sets the items in aComponents to the same size. Sets each component's preferred and maximum sizes. The actual size is determined by the layout manager, which adjusts for locale-specific strings and customized fonts. (See this Sun doc for more information.)

Parameters:
components - contains JComponent objects.

createStandardTextArea

public static JTextArea createStandardTextArea(int rows,
                                               int columns)

createStandardTextArea

public static JTextArea createStandardTextArea(String text)
An alternative to multi-line labels, for the presentation of several lines of text, and for which the line breaks are determined solely by the control.

Parameters:
text - text that does not contain newline characters or html.
Returns:
JTextArea which is not editable, has improved spacing over the supplied default (placing UIConstants.ONE_SPACEon the left and right), and which wraps lines on word boundarie.

configureStandardTextArea

public static JTextArea configureStandardTextArea(JTextArea textArea)

createStandardTextAreaHardNewLines

public static JTextArea createStandardTextAreaHardNewLines(String text)
An alternative to multi-line labels, for the presentation of several lines of text, and for which line breaks are determined solely by aText, and not by the control.

Parameters:
text - the text to be placed in the text area.
Returns:
JTextArea which is not editable and has improved spacing over the supplied default (placing UIConstants.ONE_SPACEon the left and right).

truncateLabelIfLong

public static void truncateLabelIfLong(JLabel label)
If aLabel has text which is longer than MAX_LABEL_LENGTH, then truncate the label text and place an ellipsis at the end; the original text is placed in a tooltip. This is particularly useful for displaying file names, whose length can vary widely between deployments.

Parameters:
label - The label to truncate if length() > MAX_LABEL_LENGTH.

textAreaAsLabel

public static JTextArea textAreaAsLabel(JTextArea textArea)
This will allow selection and copy to work but still retain the label look


textComponentAsLabel

public static JTextComponent textComponentAsLabel(JTextComponent textcomponent)
This will allow selection and copy to work but still retain the label look


createDebugBorder

public static void createDebugBorder(JComponent c,
                                     Color color)
Useful debug function to place a colored, line border around a component for layout management debugging.

Parameters:
c - the component
color - the border color


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.