|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.jpf.JPF
The Java Power Framework class JPF provides the
foundation for creating an automatic Java GUI application with access
to the JPT console and a graphics window and to automatically created
action buttons. Specifically, the automatic objects available are:
console accessed via the interface
ConsoleAwarewindow defined using a
BufferedPanelsequence of type
PaintableSequence
associated with the graphics windowThe automatic action buttons are created from the public
methods in the class (or chain of classes) derived from JPF
that satisfy the following conditions.
The arguments and return types of the public methods
may be chosen from the following types:
boolean, char, byte, short, int, long, float, double.String, Color, BigInteger, BigDecimalStringable interfaceIn addition, the return types of the public methods
may also be chosen from the following types:
voidPaintFor each public method that satisfies the above conditions,
there is an action button created that executes the method. Method names
may be overloaded. The tooltip that is shown when the mouse hovers over
an action button will give the full method signature. For a method that
has non-trivial arguments or a non-void return type, the click
of the action button will bring up an auxiliary GUI so the arguments may be
provided and the return value may be shown.
The creation of the automatic Java GUI application is accomplished by a combination of Java reflection and the use of the rest of the Java Power Tools. Since these techniques are encapsulated, a beginner may use the Java Power Framework without any specific knowledge of the JPT.
To use the Java Power Framework class JPF, simply
define a class that extends JPF, directly or indirectly,
and execute a constructor on that new class. The constructor may
implicitly call the default JPF constructor or may call one
of the non-default JPF constructors using super.
For example, if a class named Methods extends the class
JPF, directly or indirectly, then all public
methods that satisfy the above constraints and are defined either in the
class Methods itself or in some intermediate class between
Methods and JPF will give rise to action buttons
in the automatically generated GUI application. These action buttons will
execute the methods used to define them.
The structure of a typical Methods class that directly
extends JPF will therefore look as follows:
public class Methods extends JPF {
public static void main(String[] args) { new Methods(); }
// enter here any member or static data declarations as desired
// enter here the public methods to be made into action buttons
// enter here any non-public helper methods as desired
}
The Java Power Framework may be used to create action buttons in an automatically generated application for any of the following purposes:
To illustrate how to define a method to launch a separate Java application
that we will name, for convenience, Foo, here is the code:
public void LaunchFoo() { Foo.main(null); }
Placing this code in the Methods class will cause a button to be
created in the automatic GUI that is labeled "LaunchFoo" and that launches
the application Foo when clicked.
It is also possible to pass arguments to the main method of a
class Foo. As on a typical command line, the arguments will be
typed in by the user as a String which will then be converted to
a String[] as required by main.
public void LaunchFoo(String arguments) {
Foo.main(Strings.tokenize(arguments, " \t\n", false));
}
Notice that the above code parses the arguments parameter using
blank, tab, and newline. This actually enables multiline arguments should that
be convenient.
It is sometimes desirable to set the look-and-feel via the tools in the
class .
Calls to such methods should be made in LookAndFeelToolsmain prior to any
constructor invocation for class Methods.
In 2.4.0, added the methods normalConsole,
iconifyConsole, maximizeConsole,
and toggleConsole.
In 2.6.0, added the member data sequence to access the paintable
sequence associated with the graphics window.
In 2.7.0, the class JPFBase was removed as a base class for class
JPF. This was a consequence of the decision to create the class
JPFApplet which allows JPF-like code to be demonstrated
in an applet. Since an applet class must derive from Applet, it was
not possible to derive JPFApplet from JPFBase. To
keep JPF and JPFApplet as parallel as possible, we made
the decision to remove the little used class JPFBase altogether.
In 2.7.0, new constructors are provided that permit the caller to determine
if the console should be visible initially and if an additional filter
should be used to prune the methods that will instantiated as buttons.
The 2.7.0 default constructor does not show the console initially
but does show the graphics window. The console may still
be opened via the “Toggle Console” button. This is a change to the
default behavior from prior versions of JPF.
In 2.7.0, the console is no longer set to the color text scheme
by default. This compensates for a Macintosh Java bug.
| Field Summary | |
protected Action |
exitAction
Default application closing action. |
PaintableSequence |
sequence
The paintable sequence of the
graphics buffered panel window. |
protected JPTFrame |
theFrame
The application frame. |
protected JPFPane |
thePane
The JPF pane. |
protected Action |
toggleConsoleAction
Toggle console action. |
protected Action |
toggleGraphicsAction
Toggle graphics action. |
BufferedPanel |
window
The graphics buffered panel window. |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface edu.neu.ccs.console.ConsoleAware |
console |
| Constructor Summary | |
JPF()
Construct the JPF application using as the given initializer the derived class that uses this default constructor. |
|
JPF(boolean showConsole)
Construct the JPF application using as the given initializer the derived class that uses this special constructor. |
|
JPF(boolean showConsole,
MethodFilter filter)
Construct the JPF application using as the given initializer the derived class that uses this special constructor. |
|
| Method Summary | |
protected void |
addToggleButtons()
Adds the two toggle buttons to the pane GUI. |
void |
clearGraphics()
Clears the graphics window. |
void |
exitFramework()
Exits the framework by calling exitFramework() on
the underlying JPFPane pane object. |
static JPTFrame |
frame(Object object)
Frame the given object in a JPTFrame and open the frame; return the frame constructed. |
static JPTFrame |
frame(Object object,
int location)
Frame the given object in a JPTFrame and open the frame; use the given location which should be either CENTER or one of the standard constants
for one of the eight compass directions;
return the frame constructed. |
static JPTFrame |
frame(Object object,
String title)
Frame the given object in a JPTFrame and open the frame; use the given title for the frame; return the frame constructed. |
static JPTFrame |
frame(Object object,
String title,
Insets insets)
Frame the given object in a JPTFrame and open the frame; use the given title for the frame; use the given insets to inset the frame in the screen; return the frame constructed. |
static JPTFrame |
frame(Object object,
String title,
int location)
Frame the given object in a JPTFrame and open the frame; use the given title for the frame; use the given location which should be either CENTER or one of the standard constants
for one of the eight compass directions;
return the frame constructed. |
static JPTFrame |
frame(Object object,
String title,
int location,
Insets insets)
Frame the given object in a JPTFrame and open the frame; use the given title for the frame; use the given location which should be either CENTER or one of the standard constants
for one of the eight compass directions;
use the given insets to inset the frame in the screen;
return the frame constructed. |
static GeneralDialog |
generalDialog(Object object,
Object[][] actionData)
Place the given object in a modal general dialog and open the dialog; use the action data to define the dialog buttons; return the dialog constructed. |
static GeneralDialog |
generalDialog(Object object,
Object[][] actionData,
Object defaultAction)
Place the given object in a modal general dialog and open the dialog; use the action data to define the dialog buttons; use the default action object to define the default button; return the dialog constructed. |
static GeneralDialog |
generalDialog(Object object,
String title,
Object[][] actionData)
Place the given object in a modal general dialog and open the dialog; use the given title for the dialog; use the action data to define the dialog buttons; return the dialog constructed. |
static GeneralDialog |
generalDialog(Object object,
String title,
Object[][] actionData,
Object defaultAction)
Place the given object in a modal general dialog and open the dialog; use the given title for the dialog; use the action data to define the dialog buttons; use the default action object to define the default button; return the dialog constructed. |
JPTFrame |
getFrame()
Returns the JPTFrame used to enclose
this JPF application. |
JPFPane |
getPane()
Returns the JPFPane used to construct
this JPF application. |
void |
iconifyConsole()
If the console is not activated then activates it;
sets the state of the console to iconify. |
boolean |
isConsoleActivated()
Returns whether or not the console is activated. |
boolean |
isGraphicsVisible()
Returns whether or not the graphics window is visible. |
void |
makeShapshot()
Makes a shapshot of the graphics window and shows
this snapshot in a separate frame. |
void |
maximizeConsole()
If the console is not activated then activates it;
sets the state of the console to maximize. |
void |
normalConsole()
If the console is not activated then activates it;
sets the state of the console to normal. |
static GeneralDialog |
OKCancelDialog(Object object)
Place the given object in a modal OK-Cancel dialog and open the dialog; return the dialog constructed. |
static GeneralDialog |
OKCancelDialog(Object object,
String title)
Place the given object in a modal OK-Cancel dialog and open the dialog; use the given title for the dialog; return the dialog constructed. |
static GeneralDialog |
OKDialog(Object object)
Place the given object in a modal OK dialog and open the dialog; return the dialog constructed. |
static GeneralDialog |
OKDialog(Object object,
String title)
Place the given object in a modal OK dialog and open the dialog; use the given title for the dialog; return the dialog constructed. |
void |
setConsoleActivated(boolean activate)
Sets the activation of the console. |
void |
setGraphicsVisible(boolean visible)
Sets the visibility of the graphics window. |
void |
showConsole()
Shows the console. |
void |
toggleConsole()
If the console is not activated then activates it;
otherwise toggles the state of the console between
normal and iconified. |
void |
toggleGraphics()
Toggles the visibility of the graphics window. |
static GeneralDialog |
YesNoCancelDialog(Object object)
Place the given object in a modal Yes-No-Cancel dialog and open the dialog; return the dialog constructed. |
static GeneralDialog |
YesNoCancelDialog(Object object,
String title)
Place the given object in a modal Yes-No-Cancel dialog and open the dialog; use the given title for the dialog; return the dialog constructed. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public BufferedPanel window
window.
public PaintableSequence sequence
sequence of the
graphics buffered panel window.
protected JPFPane thePane
protected JPTFrame theFrame
protected Action toggleGraphicsAction
protected Action toggleConsoleAction
protected Action exitAction
Default application closing action. Calls:
setConsoleActivated(false);
System.exit(0);
| Constructor Detail |
public JPF()
Construct the JPF application using as the given initializer the derived class that uses this default constructor.
This constructor shows the graphics window initially
but does not show the console.
public JPF(boolean showConsole)
Construct the JPF application using as the given initializer the derived class that uses this special constructor.
This constructor shows the graphics window initially
and shows the console if the given boolean parameter is true.
showConsole - whether or not to initially show the console
public JPF(boolean showConsole,
MethodFilter filter)
Construct the JPF application using as the given initializer the derived class that uses this special constructor.
This constructor shows the graphics window initially
and shows the console if the given boolean parameter is true;
uses the given filter to filter the methods used for buttons.
showConsole - whether or not to initially show the consolefilter - an optional method filter to filter the methods used for buttons| Method Detail |
public final JPFPane getPane()
Returns the JPFPane used to construct
this JPF application.
public final JPTFrame getFrame()
Returns the JPTFrame used to enclose
this JPF application.
public final void showConsole()
Shows the console.
No longer sets the console to the color text scheme
by default. This compensates for a Macintosh Java bug.
public final boolean isConsoleActivated()
console is activated.
public final void setConsoleActivated(boolean activate)
Sets the activation of the console.
Does nothing if activation will not change.
activate - the desired activation settingpublic final void normalConsole()
console is not activated then activates it;
sets the state of the console to normal.
public final void iconifyConsole()
console is not activated then activates it;
sets the state of the console to iconify.
public final void maximizeConsole()
console is not activated then activates it;
sets the state of the console to maximize.
public final void toggleConsole()
console is not activated then activates it;
otherwise toggles the state of the console between
normal and iconified.
public final void clearGraphics()
window.
public final boolean isGraphicsVisible()
window is visible.
public final void setGraphicsVisible(boolean visible)
Sets the visibility of the graphics window.
Does nothing if visibility will not change.
visible - the desired visibility settingpublic final void toggleGraphics()
window.
public final void makeShapshot()
Makes a shapshot of the graphics window and shows
this snapshot in a separate frame.
This facility is provided to make it easy for users to create a
snapshot of the graphics window that may then be saved
by utilities that can capture a frame.
This method works whether or not the graphics window
is currently visible on screen.
The programmer may make the following call to capture the graphics
window to a BufferedImage in order to
save the data in a specific format or to do further manipulation.
BufferedImage snapshot = window.makeSnapshot();
public final void exitFramework()
Exits the framework by calling exitFramework() on
the underlying JPFPane pane object. In turn, this
method invokes the doClick method on the exit button.
This procedure guarantees that the exit behavior will be identical
to the action attached to the exit button.
protected final void addToggleButtons()
public static JPTFrame frame(Object object)
Frame the given object in a JPTFrame and open the frame; return the frame constructed.
object - the object to frame
public static JPTFrame frame(Object object,
int location)
Frame the given object in a JPTFrame
and open the frame;
use the given location which should be either
CENTER or one of the standard constants
for one of the eight compass directions;
return the frame constructed.
object - the object to framelocation - the constant representing the frame location
public static JPTFrame frame(Object object,
String title)
Frame the given object in a JPTFrame and open the frame; use the given title for the frame; return the frame constructed.
object - the object to frametitle - the title for the frame
public static JPTFrame frame(Object object,
String title,
int location)
Frame the given object in a JPTFrame
and open the frame;
use the given title for the frame;
use the given location which should be either
CENTER or one of the standard constants
for one of the eight compass directions;
return the frame constructed.
object - the object to frametitle - the title for the framelocation - the constant representing the frame location
public static JPTFrame frame(Object object,
String title,
Insets insets)
Frame the given object in a JPTFrame and open the frame; use the given title for the frame; use the given insets to inset the frame in the screen; return the frame constructed.
object - the object to frametitle - the title for the frameinsets - the screen insets to use to adjust the location
public static JPTFrame frame(Object object,
String title,
int location,
Insets insets)
Frame the given object in a JPTFrame
and open the frame;
use the given title for the frame;
use the given location which should be either
CENTER or one of the standard constants
for one of the eight compass directions;
use the given insets to inset the frame in the screen;
return the frame constructed.
object - the object to frametitle - the title for the framelocation - the constant representing the frame locationinsets - the screen insets to use to adjust the location
public static GeneralDialog OKDialog(Object object)
Place the given object in a modal OK dialog and open the dialog; return the dialog constructed.
object - the object to place in the dialog
public static GeneralDialog OKDialog(Object object,
String title)
Place the given object in a modal OK dialog and open the dialog; use the given title for the dialog; return the dialog constructed.
object - the object to place in the dialogtitle - the title for the dialog
public static GeneralDialog OKCancelDialog(Object object)
Place the given object in a modal OK-Cancel dialog and open the dialog; return the dialog constructed.
object - the object to place in the dialog
public static GeneralDialog OKCancelDialog(Object object,
String title)
Place the given object in a modal OK-Cancel dialog and open the dialog; use the given title for the dialog; return the dialog constructed.
object - the object to place in the dialogtitle - the title for the dialog
public static GeneralDialog YesNoCancelDialog(Object object)
Place the given object in a modal Yes-No-Cancel dialog and open the dialog; return the dialog constructed.
object - the object to place in the dialog
public static GeneralDialog YesNoCancelDialog(Object object,
String title)
Place the given object in a modal Yes-No-Cancel dialog and open the dialog; use the given title for the dialog; return the dialog constructed.
object - the object to place in the dialogtitle - the title for the dialog
public static GeneralDialog generalDialog(Object object,
Object[][] actionData)
Place the given object in a modal general dialog and open the dialog; use the action data to define the dialog buttons; return the dialog constructed.
The parameter actionData
is an Object[][] array that specifies
each dialog Action in one of the following ways:
ActionIf the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:
- DialogAction.KEEP_OPEN
- DialogAction.AUTO_CLOSE
- DialogAction.SET_CANCEL
If the option parameter is not specified, it is taken to be
DialogAction.AUTO_CLOSE.
object - the object to place in the dialogactionData - the action data
public static GeneralDialog generalDialog(Object object,
Object[][] actionData,
Object defaultAction)
Place the given object in a modal general dialog and open the dialog; use the action data to define the dialog buttons; use the default action object to define the default button; return the dialog constructed.
The parameter actionData
is an Object[][] array that specifies
each dialog Action in one of the following ways:
ActionIf the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:
- DialogAction.KEEP_OPEN
- DialogAction.AUTO_CLOSE
- DialogAction.SET_CANCEL
If the option parameter is not specified, it is taken to be
DialogAction.AUTO_CLOSE.
The Object supplied for the default action must either be
an Action or a name that is supplied in the action data. If
the parameter is null, no default action is set.
object - the object to place in the dialogactionData - the action datadefaultAction - the default action
public static GeneralDialog generalDialog(Object object,
String title,
Object[][] actionData)
Place the given object in a modal general dialog and open the dialog; use the given title for the dialog; use the action data to define the dialog buttons; return the dialog constructed.
The parameter actionData
is an Object[][] array that specifies
each dialog Action in one of the following ways:
ActionIf the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:
- DialogAction.KEEP_OPEN
- DialogAction.AUTO_CLOSE
- DialogAction.SET_CANCEL
If the option parameter is not specified, it is taken to be
DialogAction.AUTO_CLOSE.
object - the object to place in the dialogtitle - the title for the dialogactionData - the action data
public static GeneralDialog generalDialog(Object object,
String title,
Object[][] actionData,
Object defaultAction)
Place the given object in a modal general dialog and open the dialog; use the given title for the dialog; use the action data to define the dialog buttons; use the default action object to define the default button; return the dialog constructed.
The parameter actionData
is an Object[][] array that specifies
each dialog Action in one of the following ways:
ActionIf the option parameter is specified, it must be one of the following values that will determine what is done to the dialog when the action is finished:
- DialogAction.KEEP_OPEN
- DialogAction.AUTO_CLOSE
- DialogAction.SET_CANCEL
If the option parameter is not specified, it is taken to be
DialogAction.AUTO_CLOSE.
The Object supplied for the default action must either be
an Action or a name that is supplied in the action data. If
the parameter is null, no default action is set.
object - the object to place in the dialogtitle - the title for the dialogactionData - the action datadefaultAction - the default action
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||