Package adams.gui.core
Class ParameterPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.core.ParameterPanel
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,ChangeListener
public class ParameterPanel extends BasePanel implements 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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected ActionListener
m_ActionListener
the action listener.protected List<Component>
m_ActualParameters
the actual parameters.protected Set<ChangeListener>
m_ChangeListeners
the change listeners.protected List<BaseCheckBox>
m_CheckBoxes
the check boxes.protected DocumentListener
m_DocumentListener
the document listener.protected int
m_GapHorizontal
the horizontal gap.protected int
m_GapVertical
the vertical gap.protected List<JLabel>
m_Labels
the labels.protected Dimension
m_MinDimensionJComboBox
the minimum dimensions for BaseComboBox components.protected List<Component>
m_Parameters
the parameters.protected Dimension
m_PreferredDimensionJSpinner
the preferred dimensions for JSpinner components.protected PropertyChangeListener
m_PropertyChangeListener
the property change listener.protected boolean
m_UseCheckBoxes
whether to use checkboxes.protected boolean
m_UseMnemonicIndicators
whether to use mnemonic indicators (_ precedes the mnemonic letter).-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
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_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, 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
Constructors Constructor Description ParameterPanel()
Initializes 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(ChangeListener l)
Adds the change listener.protected void
addChangeListenerTo(Component comp)
Adds a change listener to the specified component.int
addParameter(boolean checked, AbstractChooserPanel chooser)
Adds the chooser panel at the end.int
addParameter(boolean checked, String label, Component comp)
Adds the label and component as new row at the end.int
addParameter(int index, boolean checked, AbstractChooserPanel chooser)
Inserts the chooser panel as new row at the specified row.int
addParameter(int index, boolean checked, String label, Component comp)
Inserts the label and component as new row at the specified row.int
addParameter(int index, boolean checked, String label, Component actual, JPanel wrapper)
Inserts the label and component as new row at the specified row.void
addParameter(int index, AbstractChooserPanel chooser)
Inserts the chooser panel as new row at the specified row.int
addParameter(int index, String label, Component comp)
Inserts the label and component as new row at the specified row.int
addParameter(int index, String label, Component actual, JPanel wrapper)
Inserts the label and component as new row at the specified row.int
addParameter(AbstractChooserPanel chooser)
Adds the chooser panel at the end.int
addParameter(String label, Component comp)
Adds the label and component as new row at the end.int
addParameter(String label, Component actual, JPanel wrapper)
Inserts the label and component as new row at the end.void
clearParameters()
Removes all parameters.protected void
fixDimensions()
Fixes the dimensions for various components.Component
getActualParameter(int index)
Returns the actual parameter component (without wrapping scroll pane etc) at the specified location.BaseCheckBox
getCheckBox(int index)
Returns the checkbof for the parameter at the specified location.JLabel
getLabel(int index)
Returns the label for the parameter at the specified location.Dimension
getMinDimensionJComboBox()
Returns the minimum dimension for BaseComboBox and derived classes.Component
getParameter(int index)
Returns the parameter component at the specified location.int
getParameterCount()
Returns the number of parameters currently displayed.Dimension
getPreferredDimensionJSpinner()
Returns the preferred dimension for JSpinner and derived classes.boolean
getUseMnemonicIndicators()
Returns whether to interpret "_" in the name as a mnemonic indicator (the next letter is to be used as mnemonic indicator).protected void
initGUI()
Initializes the members.protected void
initialize()
Initializes the members.boolean
isChecked(int index)
Returns whether the checkbox is ticked.protected void
notifyChangeListeners()
Notifies all the change listeners.void
removeChangeListener(ChangeListener l)
Removes the change listener.protected void
removeChangeListenerFrom(Component comp)
Removes a change listener from the specified component.void
removeParameter(int index)
Removes the parameter at the specified location.void
setEnabled(boolean enabled)
Sets the enabled state of the panel.void
setMinDimensionJComboBox(Dimension value)
Sets the minimum dimension for BaseComboBox and derived classes.void
setPreferredDimensionJSpinner(Dimension value)
Sets the preferred dimension for JSpinner and derived classes.void
setToolTipText(int index, String text, boolean label, boolean comp)
Sets the tiptext to display.void
setToolTipText(int index, String text, boolean check, boolean label, boolean comp)
Sets the tiptext to display.void
setUseMnemonicIndicators(boolean value)
Sets whether to interpret "_" in the name as a mnemonic indicator (the next letter is to be used as mnemonic indicator).void
stateChanged(ChangeEvent e)
Invoked when the target of the listener has changed its state.protected void
update()
Updates the layout.boolean
useCheckBoxes()
Returns whether checkboxes are used.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods 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, unregisterKeyboardAction, update
-
Methods 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, validateTree
-
Methods 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 Detail
-
m_CheckBoxes
protected List<BaseCheckBox> m_CheckBoxes
the check boxes.
-
m_GapHorizontal
protected int m_GapHorizontal
the horizontal gap.
-
m_GapVertical
protected int m_GapVertical
the vertical gap.
-
m_UseCheckBoxes
protected boolean m_UseCheckBoxes
whether to use checkboxes.
-
m_UseMnemonicIndicators
protected boolean m_UseMnemonicIndicators
whether to use mnemonic indicators (_ precedes the mnemonic letter).
-
m_PreferredDimensionJSpinner
protected Dimension m_PreferredDimensionJSpinner
the preferred dimensions for JSpinner components.
-
m_MinDimensionJComboBox
protected Dimension m_MinDimensionJComboBox
the minimum dimensions for BaseComboBox components.
-
m_ChangeListeners
protected Set<ChangeListener> m_ChangeListeners
the change listeners.
-
m_DocumentListener
protected DocumentListener m_DocumentListener
the document listener.
-
m_ActionListener
protected ActionListener m_ActionListener
the action listener.
-
m_PropertyChangeListener
protected PropertyChangeListener m_PropertyChangeListener
the property change listener.
-
-
Constructor Detail
-
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 Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classBasePanel
-
clearParameters
public void clearParameters()
Removes all parameters.
-
useCheckBoxes
public boolean useCheckBoxes()
Returns whether checkboxes are used.- Returns:
- true if checkboxes are used
-
setUseMnemonicIndicators
public void setUseMnemonicIndicators(boolean value)
Sets whether to interpret "_" in the name as a mnemonic indicator (the next letter is to be used as mnemonic indicator).- Parameters:
value
- true if to use mnemonic indicators
-
getUseMnemonicIndicators
public boolean getUseMnemonicIndicators()
Returns whether to interpret "_" in the name as a mnemonic indicator (the next letter is to be used as mnemonic indicator).- Returns:
- true if to use mnemonic indicators
-
setPreferredDimensionJSpinner
public void setPreferredDimensionJSpinner(Dimension value)
Sets the preferred dimension for JSpinner and derived classes.- Parameters:
value
- the preferred dimensions (do not use 0 for height!)
-
getPreferredDimensionJSpinner
public Dimension getPreferredDimensionJSpinner()
Returns the preferred dimension for JSpinner and derived classes.- Returns:
- the preferred dimensions
-
setMinDimensionJComboBox
public void setMinDimensionJComboBox(Dimension value)
Sets the minimum dimension for BaseComboBox and derived classes.- Parameters:
value
- the minimum dimensions (do not use 0 for height!)
-
getMinDimensionJComboBox
public Dimension getMinDimensionJComboBox()
Returns the minimum dimension for BaseComboBox and derived classes.- Returns:
- the minimum dimensions
-
addParameter
public int addParameter(String label, Component comp)
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
public int addParameter(boolean checked, String label, Component comp)
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
public int addParameter(AbstractChooserPanel chooser)
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:
useCheckBoxes()
-
addParameter
public int addParameter(boolean checked, AbstractChooserPanel chooser)
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:
useCheckBoxes()
-
addParameter
public int addParameter(int index, String label, Component comp)
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
public int addParameter(int index, boolean checked, String label, Component comp)
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
public int addParameter(String label, Component actual, JPanel wrapper)
Inserts the label and component as new row at the end.- Parameters:
label
- the label to add, the mnemonic to use is preceded by "_"actual
- the actual, non-wrapped component to addwrapper
- the wrapped component- Returns:
- the index of the parameter
-
addParameter
public int addParameter(int index, String label, Component actual, JPanel wrapper)
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 "_"actual
- the actual, non-wrapped component to addwrapper
- the wrapped component- Returns:
- the index of the parameter
-
addParameter
public int addParameter(int index, boolean checked, String label, Component actual, JPanel wrapper)
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 "_"actual
- the actual, non-wrapped component to addwrapper
- the wrapped component- Returns:
- the index of the parameter
-
addParameter
public void addParameter(int index, AbstractChooserPanel chooser)
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
public int addParameter(int index, boolean checked, AbstractChooserPanel chooser)
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
public Component getParameter(int index)
Returns the parameter component at the specified location.- Parameters:
index
- the row index- Returns:
- the requested component
-
getActualParameter
public Component getActualParameter(int index)
Returns the actual parameter component (without wrapping scroll pane etc) 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
public JLabel getLabel(int index)
Returns the label for the parameter at the specified location.- Parameters:
index
- the row index- Returns:
- the requested label
-
getCheckBox
public BaseCheckBox getCheckBox(int index)
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:
useCheckBoxes()
-
isChecked
public boolean isChecked(int index)
Returns whether the checkbox is ticked.- Parameters:
index
- the row index- Returns:
- true if checked
-
setToolTipText
public void setToolTipText(int index, String text, boolean label, boolean comp)
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
public void setToolTipText(int index, String text, boolean check, boolean label, boolean comp)
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:
setEnabled
in classJComponent
- Parameters:
enabled
- if true then the parameters will be editable
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds the change listener.- Parameters:
l
- the change listener
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes the change listener.- Parameters:
l
- the change listener
-
notifyChangeListeners
protected void notifyChangeListeners()
Notifies all the change listeners.
-
stateChanged
public void stateChanged(ChangeEvent e)
Invoked when the target of the listener has changed its state.- Specified by:
stateChanged
in interfaceChangeListener
- Parameters:
e
- a ChangeEvent object
-
addChangeListenerTo
protected void addChangeListenerTo(Component comp)
Adds a change listener to the specified component.- Parameters:
comp
- the component to add the listener to
-
removeChangeListenerFrom
protected void removeChangeListenerFrom(Component comp)
Removes a change listener from the specified component.- Parameters:
comp
- the component to remove the listener from
-
-