Class COM.bensoft.base.BensUtils
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.bensoft.base.BensUtils

java.lang.Object
   |
   +----COM.bensoft.base.BensUtils

public class BensUtils
extends Object
BensUtils implements simple utilities that are used in various places. The methods are all static.

Author:
Michael Benson

Constructor Index

 o BensUtils()

Method Index

 o capitalizePhrase(String)
Capitalize all words in a phrase.
 o createMenuMar(String[])
Create a menu bar.
 o getIndefiniteArticle(String, boolean)
Get the indefinite article that should precede a word.

Constructors

 o BensUtils
  public BensUtils()

Methods

 o capitalizePhrase
  public static String capitalizePhrase(String str)
Capitalize all words in a phrase. The input string can have any number of words separated by spaces. All words will be capitalized.
Parameters:
str - the string to be capitalized.
 o getIndefiniteArticle
  public static String getIndefiniteArticle(String str,
                                            boolean capitalize)
Get the indefinite article that should precede a word. Words that begin with a vowel should return "an". Words that begin with a consonant should return "a".
Parameters:
str - the word to be preceded by indefinite article.
capitalize - true if article is to be capitalized, false if not.
 o createMenuMar
  public static MenuBar createMenuMar(String menuStrs[])
Create a menu bar. The input is an array of strings. Each string contains the text of the menu or menu item. If the string begins with ">", it is a menu item to be added to the last menu. If it begins with "-", a separator is to be added. For example, suppose the input strings are as follows:

		String menuStrs[] = {"File", ">Open", "-", ">Quit", "Edit", ">Clear"};
This will create two menus, "File" and "Edit". The "File" menu will contain 3 items, "Open", a separator, and "Quit". The "Edit" menu will contain 1 item, "Clear".

Eventually, you should be able to add command keys (accelerators) by using the following form: ">Quit#Q". This will add a menu item "Quit" with the command key equivalent "Q". This is not implemented yet, however you can use the command key notation and nothing will happen for now.

Parameters:
menuStrs - an array of menu and menu item strings.
Returns:
the newly constructed menu bar.

All Packages  Class Hierarchy  This Package  Previous  Next  Index