package Widgets105

jlouie 9.96
supplied AS_IS.
free for non_commercial use.

A set of reusable Java classes:

1)  TabInterface.java TabMethods.java

These interfaces support tabbing between "smart" components.
TabTextField and TabButton implement the TabInterface allowing
the user to tab between buttons and textfields!

public interface TabInterface
{
   public void RequestFocusForward();
   public void RequestFocusReverse();
   public void SetNextComponent(TabInterface ti);
   public void SetPrevComponent(TabInterface ti);
   public Component GetNextComponent();
   public Component GetPrevComponent();
}

The implementing class should perform class specific tasks in
response to RequestFocusForward. For instance, in TabTextField 
RequestFocusForward calls requestFocus and selectAll.  If the 
textfield is not editable RequestFocusForward will "pass the
batton" to the next smart component.

The class interface method:

public static void SetTabComponents(TabInterface[] ti)

automagically sets the tab order when passed an array of 
Components that implement the TabInterface:

Sample Code:
TabInterface[] ti= new TabInterface[arrayFields.length];
for (int i=0; i<arrayFields.length; i++)
{ti[i]= (TabInterface)arrayFields[i];}
TabMethods.SetTabComponents(ti);

1)  TabTextField.java:

An object oriented TextField that supports tab, shift-tab and
key filters. This version does not trap the return key.

NUMERIC_ONLY accepts .,0 to 9
SIGNED_NUMERIC_ONLY accepts -.,0 to 9
PHONE_ONLY accepts - 0 to 9
CUSTOM_KEY accepts any key in String customKey

constants NO_KEY_FILTER, NUMERIC_ONLY, DIGITS_ONLY, PHONE_ONLY
CUSTOM_KEY, SIGNED_NUMERIC_ONLY.
  
constructor TabTextField(String str, int col)
TabTextField(String str, int col, int keyFilter)
TabTextField(String str, int col, int keyFilter, String customKey)

Sample code:
TabTextField[] arrayFields= new TabTextField[2];
arrayFields[0]= new TabTextField("Area Code",3,TabTextField.DIGITS_ONLY);
arrayFields[1]= new TabTextField("W",1,TabTextField.CUSTOM_KEY,"HWFCP");
TabInterface[] ti= new TabInterface[arrayFields.length];
for (int i=0; i<arrayFields.length; i++)
{ti[i]= (TabInterface)arrayFields[i];}
TabMethods.SetTabComponents(ti);

2) MyDialog.java:

This class creates a one, two or three button custom dialog box.
This version supports DoDestroy() allowing the calling class to
respond to a DESTROY_WINDOW event.
This version supports tabbing between buttons.

interface DialogInterface.java:
ButtonOne(String label);
ButtonTwo(String label);
ButtonThree(String label);
DoDestroy(String title);	// DESTROY_WINDOW event

constants NO_DEFAULT, BUTTON_ONE, BUTTON_TWO, BUTTON_THREE
constructor MyDialog(Frame f) // default DialogBox,Confirm,?,OK,BUTTON_ONE
MyDialog(Frame f, String title);
MyDialog(Frame f, String title, String mess1)
MyDialog(Frame f, String title, String mess1, String mess2)
MyDialog(Frame f, String title, String mess1, String mess2, int defaultButton)
MyDialog(Frame f, String title, String mess1, String mess2, int defaultButton,
	String buttonOne)
MyDialog(Frame f, String title, String mess1, String mess2, int defaultButton,
	String buttonOne, String buttonTwo)
MyDialog(Frame f, String title, String mess1, String mess2, int defaultButton,
	String buttonOne, String buttonTwo, String buttonThree)

Sample Code:
MyDialog dl= null;  
void DoAboutBox()
{
	if (dl != null)
	{
		if (dl.isShowing()) dl.hide();
		dl.dispose();
		dl= null;
	}
	dl= new MyDialog(this,"About Box","Widgets v1.03","jlouie 9.96");
}

public void ButtonOne(String label) {this.toFront();}
public void ButtonTwo(String label) {;}
public void ButtonThree(String label) {;}
public void DoDestroy(String title) {this.toFront();}

3) TabButton.java

Extends Button and implements the TabInterface supporting
tabbing between buttons AND/OR textfields.

constructors
TabButton(String label);

TabButton tab order can be set using the interface class method
SetTabComponents(TabInterface[] ti)

4)  Format.java:
Formats a double or Double to a non-exponential string with or without commas.

class methods 
public static String ToString(Double db);
public static String ToString(double d);
public static String ToCommaString(Double db);
public static String ToCommaString(double d);

double d= 999999.5;
String str= Format.ToCommaString(d);
output 1,000,000

Have fun with Java,
Jeff		