|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.swing.BorderUtils
public class BorderUtils
Helper methods for applying resource bundle related borders.
Often one finds themselves putting borders around a group of GUI
objects. This class provides some standard "border" looks that are
able to retrieve configuration and textual information directly
from resource bundles.
Resources| Constructor Summary | |
|---|---|
BorderUtils()
|
|
| Method Summary | |
|---|---|
static void |
addTitledBorder(JPanel pan,
String title,
int w)
Add a simple lined border with some title text to a JPanel |
static void |
addTitledBorder(JPanel pan,
TagLookup tl)
Add a border based on values pulled from a TagLookup object. |
static void |
addTitledBorder(JPanel pan,
TagLookup tl,
Object[] args)
Add a border based on values pulled from a TagLookup object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BorderUtils()
| Method Detail |
|---|
public static void addTitledBorder(JPanel pan,
String title,
int w)
JPanel
pan - The JPanel to add a titled border to (if you pass
null, we do nothing).title - The text title to display (you can pass null or a 0 length
title if you don't need a text string displayed)w - The width of the border area (values less than 0 will get the
default value)
public static void addTitledBorder(JPanel pan,
TagLookup tl,
Object[] args)
TagLookup object.
This method puts a border around a panel area based upon
properties loaded from TagLookup object. It is
similar to the addTitledBorder(javax.swing.JPanel, java.lang.String, int) method except that it
pulls both the title and border with from the passed property
file.
The following properties are recognized:
This implementation allows one to dynmacically subsitute program variables into the title created. For example, consider the property file:
border.title={0} Server Properties
border.width=5
By passing a non-null array of arguments as the third
parameter, we can have the "{0}" subsituted with our first array
entry. Refer to the MessageFormat class for
more details on this. Here is what the corresponding code might
look like (which would result in a title of "Time Server
Properties"):
public static JPanel createTimePanel(ResourceBundle rb) {
JPanel pan = new JPanel();
Lookup l = LookupCreate.fromResourceBundle(rb);
TagLookup tl = new TagLookup(l,"border");
Object[] args = { "Time" };
BorderUtils.addTitledBorder(pan,tl,args);
return pan;
}
pan - The JPanel to add a titled border to (if you pass
null, we do nothing).tl - The TagLookup object to get the properties from.args - Pass 'null' if you want to use the title exactly as it is
retrieved from the resources (tl). Pass an array objects if
you to subsitute values corresponding to the rules of the
MessageFormat class.
public static void addTitledBorder(JPanel pan,
TagLookup tl)
TagLookup object.
This method puts a border around a panel area based upon
properties loaded from TagLookup object. It is
similar to the addTitledBorder(javax.swing.JPanel, java.lang.String, int) method except that it
pulls both the title and border with from the passed property
file.
The following properties are recognized:
pan - The JPanel to add a titled border to (if you pass
null, we do nothing).tl - The TagLookup object to get the properties from.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||