Class 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:
  • Field Details

    • m_CheckBoxes

      protected List<JCheckBox> m_CheckBoxes
      the check boxes.
    • m_Labels

      protected List<JLabel> m_Labels
      the labels.
    • m_Parameters

      protected List<Component> m_Parameters
      the parameters.
    • 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_PreferredDimensionJSpinner

      protected Dimension m_PreferredDimensionJSpinner
      the preferred dimensions for JSpinner components.
    • m_MinDimensionJComboBox

      protected Dimension m_MinDimensionJComboBox
      the minimum dimensions for JComboBox 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 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 pixel
      vgap - the vertical gap in pixel
    • ParameterPanel

      public ParameterPanel(int hgap, int vgap, boolean useCheckBoxes)
      Initializes the panel.
      Parameters:
      hgap - the horizontal gap in pixel
      vgap - the vertical gap in pixel
      useCheckBoxes - whether to use checkboxes
  • Method Details

    • initialize

      protected void initialize()
      Initializes the members.
      Overrides:
      initialize in class BasePanel
    • initGUI

      protected void initGUI()
      Initializes the members.
      Overrides:
      initGUI in class BasePanel
    • clearParameters

      public void clearParameters()
      Removes all parameters.
    • useCheckBoxes

      public boolean useCheckBoxes()
      Returns whether checkboxes are used.
      Returns:
      true if checkboxes are used
    • 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 JComboBox and derived classes.
      Parameters:
      value - the minimum dimensions (do not use 0 for height!)
    • getMinDimensionJComboBox

      public Dimension getMinDimensionJComboBox()
      Returns the minimum dimension for JComboBox 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 checked
      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(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:
    • 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:
    • 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 end
      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(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 end
      checked - whether the checkbox is checked
      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 void addParameter(int index, AbstractChooserPanel chooser)
      Inserts the chooser panel as new row at the specified row.
      Parameters:
      chooser - the chooser panel to insert
      index - 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 end
      checked - whether the checkbox is checked
      chooser - 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
    • 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 JCheckBox 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:
    • 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 component
      text - the tiptext to use, null to turn off
      label - whether to set the tiptext for the label
      comp - 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 component
      text - the tiptext to use, null to turn off
      check - whether to set the tiptext for the checkbox
      label - whether to set the tiptext for the label
      comp - whether to set the tiptext for the component (must be JComponent)
    • fixDimensions

      protected void fixDimensions()
      Fixes the dimensions for various components.
      See Also:
    • update

      protected void update()
      Updates the layout.
    • setEnabled

      public void setEnabled(boolean enabled)
      Sets the enabled state of the panel.
      Overrides:
      setEnabled in class JComponent
      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 interface ChangeListener
      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