|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectComponent
Container
JComponent
JPanel
FormatChooser
public class FormatChooser
Select the pattern to use for formating numbers, angles or dates.
This widget can be used with one of Format
objects working with pattern, like
DecimalFormat
, SimpleDateFormat
or AngleFormat
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected Format |
format
The format to configure by this FormatChooser . |
Fields inherited from class JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
FormatChooser(Format format)
Constructs a pattern chooser for the given format. |
Method Summary | |
---|---|
Format |
getFormat()
Returns the current format. |
String |
getPattern()
Returns the localized pattern for the current format. |
Object |
getSampleValue()
Returns the sample value to format as a "preview" text. |
static void |
main(String[] args)
Show this component. |
void |
setFormat(Format format)
Set the format to configure. |
void |
setPattern(String pattern)
Sets the localized pattern for the current format. |
void |
setSampleValue(Object value)
Sets the sample value to format as a "preview" text. |
boolean |
showDialog(Component owner,
String title)
Shows a dialog box requesting input from the user. |
Methods inherited from class JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Format format
FormatChooser
.
Constructor Detail |
---|
public FormatChooser(Format format) throws IllegalArgumentException
format
- The format to configure. The default implementation accept instance of
DecimalFormat
, SimpleDateFormat
or AngleFormat
.
IllegalArgumentException
- if the format is invalid.Method Detail |
---|
public Format getFormat()
public void setFormat(Format format) throws IllegalArgumentException
DecimalFormat
, SimpleDateFormat
or AngleFormat
. If
more format class are wanted, methods getPattern()
and setPattern(java.lang.String)
should be overridden.
format
- The format to congifure.
IllegalArgumentException
- if the format is invalid.public Object getSampleValue()
null
.
public void setSampleValue(Object value) throws IllegalArgumentException
getFormat()
.
value
- The value to format, or null
.
IllegalArgumentException
- if the value can't be formatted.public String getPattern() throws IllegalStateException
DecimalFormat
, SimpleDateFormat
and AngleFormat
instances.
IllegalStateException
- is the current format is not one of recognized type.public void setPattern(String pattern) throws IllegalStateException, IllegalArgumentException
DecimalFormat
, SimpleDateFormat
and AngleFormat
instances.
pattern
- The pattern for the current format.
IllegalStateException
- is the current format is not one of recognized type.
IllegalArgumentException
- if the specified pattern is invalid.public boolean showDialog(Component owner, String title)
owner
. If owner
is contained into a
JDesktopPane
, the dialog box will appears as an internal
frame. This method can be invoked from any thread (may or may not be the
Swing thread).
owner
- The parent component for the dialog box,
or null
if there is no parent.title
- The dialog box title.
true
if user pressed the "Ok" button, or
false
otherwise (e.g. pressing "Cancel"
or closing the dialog box from the title bar).public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |