com.ccg.swing
Class BorderUtils

java.lang.Object
  extended by com.ccg.swing.BorderUtils

public class BorderUtils
extends Object

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.

Since:
1.0
Version:
$Revision: 1.3 $
Author:
$Author: pkb $
See Also:
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

BorderUtils

public BorderUtils()
Method Detail

addTitledBorder

public static void addTitledBorder(JPanel pan,
                                   String title,
                                   int w)
Add a simple lined border with some title text to a JPanel

Parameters:
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)
Since:
1.0

addTitledBorder

public static void addTitledBorder(JPanel pan,
                                   TagLookup tl,
                                   Object[] args)
Add a border based on values pulled from a 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:

[TAG].title=STRING
The title to be displayed with the border.
[TAG].width=INT
The number of pixels wide the border should be.

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;
 }
 

Parameters:
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.
Since:
1.0

addTitledBorder

public static void addTitledBorder(JPanel pan,
                                   TagLookup tl)
Add a border based on values pulled from a 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:

[TAG].title=STRING
The title to be displayed with the border.
[TAG].width=INT
The number of pixels wide the border should be.

Parameters:
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.
Since:
1.0


Copyright 1998-1998-2006 null. All Rights Reserved.