Swing utility tasks
A utility class which collects common tasks can greatly reduce code duplication. This is especially true for Swing, where many elements of GUI construction are repetitive.
The UiUtil class has a number of static methods for:
- centering windows on the screen, or with respect to a parent window
- equalizing sizes of components
- imposing an alignment on all items in a Box
- creating borders of a standard size
- creating dialog titles of a standard format
- retrieving images
- creating pairs of components, both for user input (JLabel and JTextField) and simple display (two JLabel objects)
- using GridBagConstraints in a concise manner
- formatting numbers, times, and percents
See Also :
Would you use this technique?