|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--EDU.ksu.cis.calculator.jnlpui.JNLPCompatibleUI
A user interface designed to be compatible with the JNLP API, so that it
will work properly under Java Web Start. This UI is appropriate for an RPN
calculator supporting integer operations. The first argument to the single
constructor gives the name of the package containing the classes that
implement the model of the calcultator. One of these classes must
be named CalculatorImpl and implement the interface
Calculator
. Furthermore, the CalculatorImpl class
must contain a 2-argument constructor whose first argument is of type
CalculatorUI
and whose second argument is of type int.
Other classes in that package which this
class will attempt to instantiate include:
Operation
.
If any of these classes are missing or cannot be constructed, their
corresponding buttons will be diabled.
This UI supports any radix 2-36 and allows conversion between them.
Buttons are provided for the digits 0-9, but any digit valid for the
current radix may be entered directly from the keyboard (see
Integer.toString(int, int)
). Keyboard equivalents are
not provided for the operations.
If a JNLP ClipboardService
is available,
a popup menu is provided for accessing the system clipboard (cut, copy,
and paste).
A checkbox is present for changing whether the bases are "sticky"; i.e.,
if the current radix
has changed since a value was pushed onto the stack and the bases are
sticky, then if that value is moved to the top of the stack, it is
displayed in the current base. Otherwise, it is displayed in the
base in which it was originally entered or computed. The model
is responsible for implementing this behavior by accepting a
Boolean
as the first argument to
Calculator.changeSettings(Object, String)
.
The Home and End keys move the text caret to the beginning and end,
respectively, of the display. Otherwise, editing keys are left to
operate as defined by the platform look-and-feel.
Constructor Summary | |
JNLPCompatibleUI(String modelLoc,
JApplet parent)
Constructs a new user interface. |
Method Summary | |
String |
getInput()
Returns any input the user has provided since the model last updated the display. |
void |
insert(String s)
Inserts the given string into the display at the text caret. |
void |
setBusy(boolean busy)
Sets the cursor to "Wait" if busy = true or "Default" otherwise. |
void |
setOutput(String s,
int b)
Displays the given String, and the given radix. |
void |
showError(Throwable e)
Displays the given Throwable in a message dialog. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JNLPCompatibleUI(String modelLoc, JApplet parent) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, ClassCastException
modelLoc
- The name of the package containing the calculator
model. The name must be terminated by a period.parent
- The applet on which the user interface is diplayed.
If the calculator is running as an application,
the applet behaves like a Panel.
ClassNotFoundException
- If there is no class CalculatorImpl
in the package specified by modelLoc.
NoSuchMethodException
- If the CalculatorImpl class does not
have a 2-arg constructor whose first
argument is of type CalculatorUI
and whose second argument is of type int.
IllegalAccessException
- If the above constructor is inaccessible.
InvocationTargetException
- If the above constructor throws an
exception.
InstantiationException
- If CalculatorImpl is an abstract class.
ClassCastException
- If CalculatorImpl does not implement
Calculator
.Method Detail |
public void insert(String s)
insert
in interface CalculatorUI
public String getInput()
getInput
in interface CalculatorUI
public void setOutput(String s, int b)
setOutput
in interface CalculatorUI
public void showError(Throwable e)
showError
in interface CalculatorUI
public void setBusy(boolean busy)
setBusy
in interface CalculatorUI
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |