|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectutil.DoubleBean
public abstract class DoubleBean
A "bean" (class with get/set methods) that records a double.
Useful with the Beanshell syntactic sugar that turns
bean.value
into bean.getValue()
and
bean.value=x
into bean.setValue(x)
.
Also includes a convenience methods to create a JTextfield,
a labelled JTextfield, a TableCellRenderer and a TableCellEditor
that reflects the value.
Field Summary | |
---|---|
static double |
LOG10
the natural logarithm of 10, for calculating log base 10 |
static java.lang.String |
MAX_STRING
a String that is larger than anything produced by toString() |
Constructor Summary | |
---|---|
DoubleBean()
|
Method Summary | |
---|---|
javax.swing.Box |
box(java.lang.String label)
Create a Swing Box that reflects this value. |
static javax.swing.table.TableCellEditor |
cellEditor()
create a cell editor that uses a DoubleBean.textfield. |
static javax.swing.table.TableCellRenderer |
cellRenderer()
create a table cell renderer that displays a number in the same format as a DoubleBean.textfield. |
abstract double |
getValue()
|
abstract void |
setValue(double x)
|
javax.swing.JTextField |
textfield()
Create a Swing JTextField that reflects this value. |
java.lang.String |
toString()
the value as a String. |
static java.lang.String |
toString(double d)
the value as a String. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final double LOG10
public static final java.lang.String MAX_STRING
toString()
Constructor Detail |
---|
public DoubleBean()
Method Detail |
---|
public abstract double getValue()
public abstract void setValue(double x)
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String toString(double d)
d
- the double to format
public javax.swing.Box box(java.lang.String label)
setValue
but the reverse is not automatically true; if setValue
is called, the text box does not change unless the subclass's
setValue
explicitly does so. However, each repaint
of this component calls getValue
, so calling
box.repaint()
after setValue
will
accomplish that.
Imposes an input verifier such that, if the edited text does not
represent a number, the text reverts to the original.
label
- the initial label on the box
public javax.swing.JTextField textfield()
setValue
but the reverse is not automatically true; if setValue
is called, the text box does not change unless the subclass's
setValue
explicitly does so. However, each repaint
of this component calls getValue
, so calling
text.repaint()
after setValue
will
accomplish that.
Imposes an input verifier such that, if the edited text does not
represent a number, the text reverts to the original.
public static javax.swing.table.TableCellRenderer cellRenderer()
java.lang.NumberFormatException
- if the value of the cell is not a Numberpublic static javax.swing.table.TableCellEditor cellEditor()
java.lang.NumberFormatException
- if the value of the cell is not a Number
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |