Package nz.ac.waikato.cms.gui.core
Class ParameterPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
nz.ac.waikato.cms.gui.core.BasePanel
nz.ac.waikato.cms.gui.core.ParameterPanel
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,EventListener,Accessible,ChangeListener
A panel that lists one parameter (label and component or just
AbstractChooserPanel) per row. The sizes of the labels get automatically
adjusted. Optionally, a checkbox can be displayed per parameter.
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ActionListenerthe action listener.protected Set<ChangeListener>the change listeners.the check boxes.protected DocumentListenerthe document listener.protected intthe horizontal gap.protected intthe vertical gap.the labels.protected Dimensionthe minimum dimensions for JComboBox components.the parameters.protected Dimensionthe preferred dimensions for JSpinner components.protected PropertyChangeListenerthe property change listener.protected booleanwhether to use checkboxes.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionInitializes the panel.ParameterPanel(boolean useCheckBoxes) Initializes the panel.ParameterPanel(int hgap, int vgap) Initializes the panel.ParameterPanel(int hgap, int vgap, boolean useCheckBoxes) Initializes the panel. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the change listener.protected voidaddChangeListenerTo(Component comp) Adds a change listener to the specified component.intaddParameter(boolean checked, String label, Component comp) Adds the label and component as new row at the end.intaddParameter(boolean checked, AbstractChooserPanel chooser) Adds the chooser panel at the end.intaddParameter(int index, boolean checked, String label, Component comp) Inserts the label and component as new row at the specified row.intaddParameter(int index, boolean checked, AbstractChooserPanel chooser) Inserts the chooser panel as new row at the specified row.intaddParameter(int index, String label, Component comp) Inserts the label and component as new row at the specified row.voidaddParameter(int index, AbstractChooserPanel chooser) Inserts the chooser panel as new row at the specified row.intaddParameter(String label, Component comp) Adds the label and component as new row at the end.intaddParameter(AbstractChooserPanel chooser) Adds the chooser panel at the end.voidRemoves all parameters.protected voidFixes the dimensions for various components.getCheckBox(int index) Returns the checkbof for the parameter at the specified location.getLabel(int index) Returns the label for the parameter at the specified location.Returns the minimum dimension for JComboBox and derived classes.getParameter(int index) Returns the parameter component at the specified location.intReturns the number of parameters currently displayed.Returns the preferred dimension for JSpinner and derived classes.protected voidinitGUI()Initializes the members.protected voidInitializes the members.booleanisChecked(int index) Returns whether the checkbox is ticked.protected voidNotifies all the change listeners.voidRemoves the change listener.protected voidRemoves a change listener from the specified component.voidremoveParameter(int index) Removes the parameter at the specified location.voidsetEnabled(boolean enabled) Sets the enabled state of the panel.voidSets the minimum dimension for JComboBox and derived classes.voidSets the preferred dimension for JSpinner and derived classes.voidsetToolTipText(int index, String text, boolean label, boolean comp) Sets the tiptext to display.voidsetToolTipText(int index, String text, boolean check, boolean label, boolean comp) Sets the tiptext to display.voidInvoked when the target of the listener has changed its state.protected voidupdate()Updates the layout.booleanReturns whether checkboxes are used.Methods inherited from class nz.ac.waikato.cms.gui.core.BasePanel
finishInitMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
m_CheckBoxes
the check boxes. -
m_Labels
the labels. -
m_Parameters
the parameters. -
m_GapHorizontal
protected int m_GapHorizontalthe horizontal gap. -
m_GapVertical
protected int m_GapVerticalthe vertical gap. -
m_UseCheckBoxes
protected boolean m_UseCheckBoxeswhether to use checkboxes. -
m_PreferredDimensionJSpinner
the preferred dimensions for JSpinner components. -
m_MinDimensionJComboBox
the minimum dimensions for JComboBox components. -
m_ChangeListeners
the change listeners. -
m_DocumentListener
the document listener. -
m_ActionListener
the action listener. -
m_PropertyChangeListener
the property change listener.
-
-
Constructor Details
-
ParameterPanel
public ParameterPanel()Initializes the panel. -
ParameterPanel
public ParameterPanel(boolean useCheckBoxes) Initializes the panel.- Parameters:
useCheckBoxes- whether to use checkboxes
-
ParameterPanel
public ParameterPanel(int hgap, int vgap) Initializes the panel.- Parameters:
hgap- the horizontal gap in pixelvgap- the vertical gap in pixel
-
ParameterPanel
public ParameterPanel(int hgap, int vgap, boolean useCheckBoxes) Initializes the panel.- Parameters:
hgap- the horizontal gap in pixelvgap- the vertical gap in pixeluseCheckBoxes- whether to use checkboxes
-
-
Method Details
-
initialize
protected void initialize()Initializes the members.- Overrides:
initializein classBasePanel
-
initGUI
protected void initGUI()Initializes the members. -
clearParameters
public void clearParameters()Removes all parameters. -
useCheckBoxes
public boolean useCheckBoxes()Returns whether checkboxes are used.- Returns:
- true if checkboxes are used
-
setPreferredDimensionJSpinner
Sets the preferred dimension for JSpinner and derived classes.- Parameters:
value- the preferred dimensions (do not use 0 for height!)
-
getPreferredDimensionJSpinner
Returns the preferred dimension for JSpinner and derived classes.- Returns:
- the preferred dimensions
-
setMinDimensionJComboBox
Sets the minimum dimension for JComboBox and derived classes.- Parameters:
value- the minimum dimensions (do not use 0 for height!)
-
getMinDimensionJComboBox
Returns the minimum dimension for JComboBox and derived classes.- Returns:
- the minimum dimensions
-
addParameter
Adds the label and component as new row at the end.- Parameters:
label- the label to add, the mnemonic to use is preceded by "_"comp- the component to add- Returns:
- the index of the parameter
-
addParameter
Adds the label and component as new row at the end.- Parameters:
checked- whether the checkbox is checkedlabel- the label to add, the mnemonic to use is preceded by "_"comp- the component to add- Returns:
- the index of the parameter
-
addParameter
Adds the chooser panel at the end. Cannot be used if checkboxes used.- Parameters:
chooser- the chooser panel to add- Returns:
- the index of the parameter
- See Also:
-
addParameter
Adds the chooser panel at the end. Cannot be used if checkboxes used.- Parameters:
chooser- the chooser panel to add- Returns:
- the index of the parameter
- See Also:
-
addParameter
Inserts the label and component as new row at the specified row.- Parameters:
index- the row index to insert the label/editfield at, -1 will add the component at the endlabel- the label to add, the mnemonic to use is preceded by "_"comp- the component to add- Returns:
- the index of the parameter
-
addParameter
Inserts the label and component as new row at the specified row.- Parameters:
index- the row index to insert the label/editfield at, -1 will add the component at the endchecked- whether the checkbox is checkedlabel- the label to add, the mnemonic to use is preceded by "_"comp- the component to add- Returns:
- the index of the parameter
-
addParameter
Inserts the chooser panel as new row at the specified row.- Parameters:
chooser- the chooser panel to insertindex- the row index to insert the label/editfield at, -1 will add the chooser at the end
-
addParameter
Inserts the chooser panel as new row at the specified row.- Parameters:
index- the row index to insert the label/editfield at, -1 will add the chooser at the endchecked- whether the checkbox is checkedchooser- the chooser panel to insert- Returns:
- the index of the parameter
-
removeParameter
public void removeParameter(int index) Removes the parameter at the specified location.- Parameters:
index- the row index
-
getParameter
Returns the parameter component at the specified location.- Parameters:
index- the row index- Returns:
- the requested component
-
getParameterCount
public int getParameterCount()Returns the number of parameters currently displayed.- Returns:
- the number of rows
-
getLabel
Returns the label for the parameter at the specified location.- Parameters:
index- the row index- Returns:
- the requested label
-
getCheckBox
Returns the checkbof for the parameter at the specified location.- Parameters:
index- the row index- Returns:
- the requested checkbox, null if not used
- See Also:
-
isChecked
public boolean isChecked(int index) Returns whether the checkbox is ticked.- Parameters:
index- the row index- Returns:
- true if checked
-
setToolTipText
Sets the tiptext to display.- Parameters:
index- the index of the componenttext- the tiptext to use, null to turn offlabel- whether to set the tiptext for the labelcomp- whether to set the tiptext for the component
-
setToolTipText
Sets the tiptext to display.- Parameters:
index- the index of the componenttext- the tiptext to use, null to turn offcheck- whether to set the tiptext for the checkboxlabel- whether to set the tiptext for the labelcomp- whether to set the tiptext for the component (must beJComponent)
-
fixDimensions
protected void fixDimensions()Fixes the dimensions for various components. -
update
protected void update()Updates the layout. -
setEnabled
public void setEnabled(boolean enabled) Sets the enabled state of the panel.- Overrides:
setEnabledin classJComponent- Parameters:
enabled- if true then the parameters will be editable
-
addChangeListener
Adds the change listener.- Parameters:
l- the change listener
-
removeChangeListener
Removes the change listener.- Parameters:
l- the change listener
-
notifyChangeListeners
protected void notifyChangeListeners()Notifies all the change listeners. -
stateChanged
Invoked when the target of the listener has changed its state.- Specified by:
stateChangedin interfaceChangeListener- Parameters:
e- a ChangeEvent object
-
addChangeListenerTo
Adds a change listener to the specified component.- Parameters:
comp- the component to add the listener to
-
removeChangeListenerFrom
Removes a change listener from the specified component.- Parameters:
comp- the component to remove the listener from
-