|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--ptolemy.gui.Query
Create a query with various types of entry boxes and controls. Each type of entry box has a colon and space appended to the end of its label, to ensure uniformity. Here is one example of creating a query with a radio button:
query = new Query(); getContentPane().add(query); String[] options = {"water", "soda", "juice", "none"}; query.addRadioButtons("radio", "Radio buttons", options, "water");
Inner classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
Inner classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Field Summary | |
protected java.awt.Color |
_background
The background color as set by setBackground(). |
protected java.awt.GridBagConstraints |
_constraints
Standard constraints for use with _grid. |
protected java.awt.GridBagLayout |
_grid
Layout control. |
protected java.util.Vector |
_listeners
List of registered listeners. |
static int |
DEFAULT_ENTRY_HEIGHT
The default height of entries created with addText(). |
static int |
DEFAULT_ENTRY_WIDTH
The default width of entries created with addLine(). |
Fields inherited from class javax.swing.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 java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
Query()
Construct a panel with no entries in it. |
Method Summary | |
protected void |
_addPair(java.lang.String name,
javax.swing.JLabel label,
java.awt.Component widget,
java.lang.Object entry)
Add a label and a widget to the panel. |
void |
addCheckBox(java.lang.String name,
java.lang.String label,
boolean defaultValue)
Create an on-off check box. |
void |
addChoice(java.lang.String name,
java.lang.String label,
java.lang.String[] values,
java.lang.String defaultChoice)
Create an uneditable choice menu. |
void |
addChoice(java.lang.String name,
java.lang.String label,
java.lang.String[] values,
java.lang.String defaultChoice,
boolean editable)
Create a choice menu. |
void |
addDisplay(java.lang.String name,
java.lang.String label,
java.lang.String theValue)
Create a simple one-line text display, a non-editable value that is set externally using the setDisplay() method. |
void |
addFileChooser(java.lang.String name,
java.lang.String label,
java.lang.String currentDirectory)
Create a FileChooser |
void |
addLine(java.lang.String name,
java.lang.String label,
java.lang.String defaultValue)
Create a single-line entry box with the specified name, label, and default value. |
void |
addQueryListener(QueryListener listener)
Add a listener. |
void |
addRadioButtons(java.lang.String name,
java.lang.String label,
java.lang.String[] values,
java.lang.String defaultValue)
Create a bank of radio buttons. |
void |
addSelectButtons(java.lang.String name,
java.lang.String label,
java.lang.String[] values,
java.util.Set initiallySelected)
Create a bank of buttons that provides a list of choices, any subset of which may be chosen at a time. |
void |
addSlider(java.lang.String name,
java.lang.String label,
int defaultValue,
int minimum,
int maximum)
Create a slider with the specified name, label, default value, maximum, and minimum. |
void |
addTextArea(java.lang.String name,
java.lang.String label,
java.lang.String theValue)
|
boolean |
booleanValue(java.lang.String name)
Deprecated. Use getBooleanValue(String name) instead. |
double |
doubleValue(java.lang.String name)
Deprecated. Use getDoubleValue(String name) instead. |
boolean |
getBooleanValue(java.lang.String name)
Get the current value in the entry with the given name and return as a boolean. |
double |
getDoubleValue(java.lang.String name)
Get the current value in the entry with the given name and return as a double value. |
int |
getIntValue(java.lang.String name)
Get the current value in the entry with the given name and return as an integer. |
java.awt.Dimension |
getMaximumSize()
Return the preferred height, but set the width to the maximum possible value. |
java.lang.String |
getStringValue(java.lang.String name)
Get the current value in the entry with the given name, and return as a String. |
int |
getTextHeight()
Get the preferred number of lines to be used for entry boxes created in using addText(). |
int |
getTextWidth()
Get the preferred width in characters to be used for entry boxes created in using addLine(). |
int |
intValue(java.lang.String name)
Deprecated. Use getIntValue(String name) instead. |
void |
notifyListeners()
Nofify listeners of the current value of all entries, unless those entries have not changed since the last notification. |
void |
removeQueryListener(QueryListener listener)
Remove a listener. |
void |
set(java.lang.String name,
java.lang.String value)
Set the value in the entry with the given name. |
void |
setAndNotify(java.lang.String name,
java.lang.String value)
Set the value in the entry with the given name and notify listeners. |
void |
setBackground(java.awt.Color color)
Set the background color for all the widgets. |
void |
setBoolean(java.lang.String name,
boolean value)
Set the current value in the entry with the given name. |
void |
setColumns(int columns)
Specify the number of columns to use. |
void |
setDisplay(java.lang.String name,
java.lang.String value)
Set the displayed text of an entry that has been added using addDisplay. |
void |
setEnabled(java.lang.String name,
boolean value)
For line, display, check box, slider, radio button, or choice entries made, if the second argument is false, then it will be disabled. |
void |
setLine(java.lang.String name,
java.lang.String value)
Set the displayed text of an item that has been added using addLine. |
void |
setMessage(java.lang.String message)
Specify a message to be displayed above the query. |
void |
setSlider(java.lang.String name,
int value)
Set the position of an item that has been added using addSlider. |
void |
setTextHeight(int characters)
Specify the preferred height to be used for entry boxes created in using addLine(). |
void |
setTextWidth(int characters)
Specify the preferred width to be used for entry boxes created in using addLine(). |
void |
setToolTip(java.lang.String name,
java.lang.String tip)
Specify a tool tip to appear when the mouse lingers over the label. |
java.lang.String |
stringValue(java.lang.String name)
Deprecated. Use getStringValue(String name) instead. |
Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUIClassID, paramString, updateUI |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int DEFAULT_ENTRY_HEIGHT
public static final int DEFAULT_ENTRY_WIDTH
protected java.awt.Color _background
protected java.awt.GridBagLayout _grid
protected java.awt.GridBagConstraints _constraints
protected java.util.Vector _listeners
Constructor Detail |
public Query()
Method Detail |
public void addCheckBox(java.lang.String name, java.lang.String label, boolean defaultValue)
name
- The name used to identify the entry (when calling get).label
- The label to attach to the entry.defaultValue
- The default value (true for on).public void addChoice(java.lang.String name, java.lang.String label, java.lang.String[] values, java.lang.String defaultChoice)
name
- The name used to identify the entry (when calling get).label
- The label to attach to the entry.values
- The list of possible choices.defaultChoice
- Default choice.public void addChoice(java.lang.String name, java.lang.String label, java.lang.String[] values, java.lang.String defaultChoice, boolean editable)
name
- The name used to identify the entry (when calling get).label
- The label to attach to the entry.values
- The list of possible choices.defaultChoice
- Default choice.editable
- True if an arbitrary choice can be entered, in addition
to the choices in values.public void addDisplay(java.lang.String name, java.lang.String label, java.lang.String theValue)
name
- The name used to identify the entry (when calling get).label
- The label to attach to the entry.theValue
- Default string to display.public void addFileChooser(java.lang.String name, java.lang.String label, java.lang.String currentDirectory)
name
- The name used to identify the entry (when calling get).label
- The label to attach to the entry.currentDirectory
- The directory to open up the file chooser in.public void addLine(java.lang.String name, java.lang.String label, java.lang.String defaultValue)
name
- The name used to identify the entry (when accessing
the entry).label
- The label to attach to the entry.defaultValue
- Default value to appear in the entry box.public void addTextArea(java.lang.String name, java.lang.String label, java.lang.String theValue)
public void addQueryListener(QueryListener listener)
listener
- The listener to add.public void addRadioButtons(java.lang.String name, java.lang.String label, java.lang.String[] values, java.lang.String defaultValue)
name
- The name used to identify the entry (when calling get).label
- The label to attach to the entry.values
- The list of possible choices.defaultValue
- Default value.public void addSelectButtons(java.lang.String name, java.lang.String label, java.lang.String[] values, java.util.Set initiallySelected)
name
- The name used to identify the entry (when calling get).label
- The label to attach to the entry.values
- The list of possible choices.initiallySelected
- The initially selected choices, or null
to indicate that none are selected.public void addSlider(java.lang.String name, java.lang.String label, int defaultValue, int minimum, int maximum) throws java.lang.IllegalArgumentException
name
- The name used to identify the slider.label
- The label to attach to the slider.defaultValue
- Initial position of slider.maximum
- Maximum value of slider.minimum
- Minimum value of slider.java.lang.IllegalArgumentException
- If the desired default value
is not between the minimum and maximum.public boolean booleanValue(java.lang.String name) throws java.util.NoSuchElementException, java.lang.IllegalArgumentException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
checkbox. This is a runtime exception, so it
need not be declared explicitly.public double doubleValue(java.lang.String name) throws java.lang.IllegalArgumentException, java.util.NoSuchElementException, java.lang.NumberFormatException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.NumberFormatException
- If the value of the entry cannot
be converted to a double. This is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
line. This is a runtime exception, so it
need not be declared explicitly.public boolean getBooleanValue(java.lang.String name) throws java.util.NoSuchElementException, java.lang.IllegalArgumentException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
checkbox. This is a runtime exception, so it
need not be declared explicitly.public double getDoubleValue(java.lang.String name) throws java.lang.IllegalArgumentException, java.util.NoSuchElementException, java.lang.NumberFormatException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.NumberFormatException
- If the value of the entry cannot
be converted to a double. This is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
line. This is a runtime exception, so it
need not be declared explicitly.public int getIntValue(java.lang.String name) throws java.lang.IllegalArgumentException, java.util.NoSuchElementException, java.lang.NumberFormatException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.NumberFormatException
- If the value of the entry cannot
be converted to an integer. This is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
choice, line, or slider. This is a runtime exception, so it
need not be declared explicitly.public java.awt.Dimension getMaximumSize()
getMaximumSize
in class javax.swing.JComponent
public int getTextWidth()
public int getTextHeight()
public java.lang.String getStringValue(java.lang.String name) throws java.util.NoSuchElementException, java.lang.IllegalArgumentException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry type does not
have a string representation (this should not be thrown).public int intValue(java.lang.String name) throws java.lang.IllegalArgumentException, java.util.NoSuchElementException, java.lang.NumberFormatException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.NumberFormatException
- If the value of the entry cannot
be converted to an integer. This is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
choice, line, or slider. This is a runtime exception, so it
need not be declared explicitly.public void notifyListeners()
public void removeQueryListener(QueryListener listener)
listener
- The listener to remove.public void set(java.lang.String name, java.lang.String value) throws java.util.NoSuchElementException, java.lang.IllegalArgumentException
name
- The name used to identify the entry (when calling get).value
- The value to set the entry to.java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the value does not parse
to the appropriate type.public void setAndNotify(java.lang.String name, java.lang.String value) throws java.util.NoSuchElementException, java.lang.IllegalArgumentException
name
- The name used to identify the entry (when calling get).value
- The value to set the entry to.java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the value does not parse
to the appropriate type.public void setBackground(java.awt.Color color)
setBackground
in class javax.swing.JComponent
color
- The background color.public void setBoolean(java.lang.String name, boolean value) throws java.util.NoSuchElementException, java.lang.IllegalArgumentException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
checkbox. This is a runtime exception, so it
need not be declared explicitly.public void setColumns(int columns)
columns
- The number of columns.public void setDisplay(java.lang.String name, java.lang.String value) throws java.util.NoSuchElementException, java.lang.IllegalArgumentException
name
- The name of the entry.value
- The string to display.java.util.NoSuchElementException
- If there is no entry with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
display. This is a runtime exception, so it
need not be declared explicitly.public void setEnabled(java.lang.String name, boolean value)
name
- The name of the entry.value
- If false, disables the entry.public void setLine(java.lang.String name, java.lang.String value)
name
- The name of the entry.value
- The string to display.java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
display. This is a runtime exception, so it
need not be declared explicitly.public void setMessage(java.lang.String message)
message
- The message to display.public void setSlider(java.lang.String name, int value)
name
- The name of the entry.value
- The value to set the slider position.java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry is not a
slider. This is a runtime exception, so it
need not be declared explicitly.public void setTextHeight(int characters)
characters
- The preferred height.public void setTextWidth(int characters)
characters
- The preferred width.public void setToolTip(java.lang.String name, java.lang.String tip)
name
- The name of the entry.tip
- The text of the tool tip.public java.lang.String stringValue(java.lang.String name) throws java.util.NoSuchElementException, java.lang.IllegalArgumentException
java.util.NoSuchElementException
- If there is no item with the
specified name. Note that this is a runtime exception, so it
need not be declared explicitly.java.lang.IllegalArgumentException
- If the entry type does not
have a string representation (this should not be thrown).protected void _addPair(java.lang.String name, javax.swing.JLabel label, java.awt.Component widget, java.lang.Object entry)
name
- The name of the entry.label
- The label.widget
- The interactive entry to the right of the label.entry
- The object that contains user data.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |