Class OptionsPanel

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

    public class OptionsPanel
    extends javax.swing.JPanel
    A panel that lays out label/component pairs vertically. The components will be layed out in the order they are added. It is useful for laying out options with label/component pairs. The default implementation in Options uses this for laying out components.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  OptionsPanel.RoundedLineBorder
      The border used for boxes when beginBorderedGroup(String, boolean).
      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      • 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
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addComponent​(javax.swing.JComponent component, boolean fillRightHandSpace)
      Add a component without a label.
      javax.swing.JLabel addComponentWithLabel​(java.lang.String label, javax.swing.JComponent component, boolean componentFillsRightHandSpace)
      Add a component with a label.
      void addComponentWithLabel​(javax.swing.JLabel label, javax.swing.JComponent component, boolean componentFillsRightHandSpace)
      Add a component with a label.
      void addDivider()
      Add a 1 pixel high, gray horizontal line which divides the components vertically.
      javax.swing.JLabel addDividerWithLabel​(java.lang.String label)
      Add a 1 pixel high, gray horizontal line which divides the components vertically.
      void addGap()
      Add an empty component which will introduce a space between the last and next component.
      void addSpanningComponent​(javax.swing.JComponent component)
      Add a component which fills the entire width of the panel.
      void addSpanningComponent​(javax.swing.JComponent component, boolean fillHorizontalSpace, int anchor)
      Add a component which spans both the label and component areas.
      void addSpanningComponent​(javax.swing.JComponent component, boolean fillHorizontalSpace, int anchor, double weighty)
      Add a component which spans both the label and component areas.
      void addTwoComponents​(javax.swing.JComponent leftComponent, javax.swing.JComponent rightComponent, boolean fillLeftHandSpace, boolean fillRightHandSpace)
      Add two components, one is instead of the label on the left.
      void addWeightedGap​(double weightY)
      Add a gap that takes up aany additional vertical space available.
      void beginBorderedGroup​(java.lang.String label, boolean headless)
      Subsequent components will be added inside a bordered sub panel.
      void endBorderedGroup()
      If we are adding components to a sub panel (see beginBorderedGroup(String, boolean)), then close off the current sub panel.
      void removeAll()  
      void setComponentPosition​(int anchor)
      Set where the components (or right component in the case of addTwoComponents(javax.swing.JComponent, javax.swing.JComponent, boolean, boolean) are positioned (normally EAST, WEST or CENTER).
      void setHorizontallyCompact​(boolean compact)
      Set whether this panel should layout its componets in a visually compact form suitable for displaying in a limited amount of space.
      void setLabelPosition​(int anchor)
      Set where the labels (or left component in the case of addTwoComponents(javax.swing.JComponent, javax.swing.JComponent, boolean, boolean) are positioned (normally EAST, WEST or CENTER).
      void setLeftAlignEverything​(boolean leftAlignEverything)
      Sets whether or not this option panel should left align all future added child components.
      void setVerticalSpacing​(int spacingBelow)
      Deprecated.
      void setVerticalSpacing​(int spacingAbove, int spacingBelow)
      Sets the spacing above and below added componenents.
      void setWeightY​(double weightY)
      Set the vertical weight of components added using methods that don't take weightY as a parameter.
      • 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, 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, 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • OptionsPanel

        public OptionsPanel​(boolean inScrollPane,
                            boolean centerLayout)
        Parameters:
        inScrollPane - true to have all the components placed inside a scroll pane.
        centerLayout - true so that the labels have equal width to the components, centering the divide between the labels and components. if false, the labels only use as much space as required.
    • Method Detail

      • setLeftAlignEverything

        public void setLeftAlignEverything​(boolean leftAlignEverything)
        Sets whether or not this option panel should left align all future added child components. This won't affect child components that have already been added to the panel.
        Parameters:
        leftAlignEverything - true to left align all options in this panel, false to keep everything standard and centred.
        Since:
        API 4.202220 (Geneious 2022.2.0)
      • setVerticalSpacing

        @Deprecated
        public void setVerticalSpacing​(int spacingBelow)
        Deprecated.
        Sets the size of the gap underneath added componenents (there is still a gap above). Default is 2.
        Parameters:
        spacingBelow - new spacing in pixels
      • setVerticalSpacing

        public void setVerticalSpacing​(int spacingAbove,
                                       int spacingBelow)
        Sets the spacing above and below added componenents. Default is 2 above and 2 below.
        Parameters:
        spacingAbove - new spacing above added components (in pixels)
        spacingBelow - new spacing below added components (in pixels)
      • addComponent

        public void addComponent​(javax.swing.JComponent component,
                                 boolean fillRightHandSpace)
        Add a component without a label. The component will be placed to the right of all other labels.
        Parameters:
        component - component to add
        fillRightHandSpace - true to make the component expand to use all space to the right of the labels. False to make it left aligned in the space to the right of the labels, at its preferred size.
        See Also:
        addSpanningComponent(javax.swing.JComponent), addSpanningComponent(javax.swing.JComponent, boolean, int)
      • addComponentWithLabel

        public javax.swing.JLabel addComponentWithLabel​(java.lang.String label,
                                                        javax.swing.JComponent component,
                                                        boolean componentFillsRightHandSpace)
        Add a component with a label.
        Parameters:
        label - label to add, will be right aligned within the space to the left of the components.
        component - component to add
        componentFillsRightHandSpace - true to make the component expand to use all space to the right of the labels. False to make it left aligned in the space to the right of the labels, at its preferred size.
        Returns:
        the JLabel which was added to the left
      • addComponentWithLabel

        public void addComponentWithLabel​(javax.swing.JLabel label,
                                          javax.swing.JComponent component,
                                          boolean componentFillsRightHandSpace)
        Add a component with a label.
        Parameters:
        label - label to add, will be right aligned within the space to the left of the components.
        component - component to add
        componentFillsRightHandSpace - true to make the component expand to use all space to the right of the labels. False to make it left aligned in the space to the right of the labels, at its preferred size.
      • addSpanningComponent

        public void addSpanningComponent​(javax.swing.JComponent component)
        Add a component which fills the entire width of the panel. Component will be anchored WEST.
        Parameters:
        component - component to add
      • addSpanningComponent

        public void addSpanningComponent​(javax.swing.JComponent component,
                                         boolean fillHorizontalSpace,
                                         int anchor)
        Add a component which spans both the label and component areas.
        Parameters:
        component - component to add.
        fillHorizontalSpace - true so that the component is expanded to fill the entire width of the panel, false to use its preferred size and the specified anchor position (below)
        anchor - where the component should be placed if fillHorizontalSpace is false. eg. GridBagConstraints.WEST, GridBagConstraints.CENTER
        See Also:
        GridBagConstraints.anchor
      • addSpanningComponent

        public void addSpanningComponent​(javax.swing.JComponent component,
                                         boolean fillHorizontalSpace,
                                         int anchor,
                                         double weighty)
        Add a component which spans both the label and component areas.
        Parameters:
        component - component to add.
        fillHorizontalSpace - true so that the component is expanded to fill the entire width of the panel, false to use its preferred size and the specified anchor position (below)
        anchor - where the component should be placed if fillHorizontalSpace is false. eg. GridBagConstraints.WEST, GridBagConstraints.CENTER
        weighty - see GridBagConstraints.weighty
        See Also:
        GridBagConstraints.anchor
      • setWeightY

        public void setWeightY​(double weightY)
        Set the vertical weight of components added using methods that don't take weightY as a parameter. Methods that have a weightY parameter will use the parameter value instead. Also doesn't affect methods that add a gap or divider. Default value is 0.0.
        Parameters:
        weightY - the vertical weight of any components added using methods that don't take weightY as a parameter
        Since:
        API version 4.610 (Geneious 6.1.0)
        See Also:
        GridBagConstraints.weighty
      • addDivider

        public void addDivider()
        Add a 1 pixel high, gray horizontal line which divides the components vertically.
      • addDividerWithLabel

        public javax.swing.JLabel addDividerWithLabel​(java.lang.String label)
        Add a 1 pixel high, gray horizontal line which divides the components vertically. Also has a text label on the left hand end, above the line.
        Parameters:
        label - text to use for the label
        Returns:
        The JLabel component created from the label String
      • addGap

        public void addGap()
        Add an empty component which will introduce a space between the last and next component.
      • addWeightedGap

        public void addWeightedGap​(double weightY)
        Add a gap that takes up aany additional vertical space available. If multiple weighted gaps are added then the additional space is divided amongst the gaps proportionally to their weight.

        For example, if a weighted gap is added as the last component in a panel, then this gap will expand to take any extra space and the other components will 'stick' to the top of the panel.

        Parameters:
        weightY - weight of the gap (see above)
      • removeAll

        public void removeAll()
        Overrides:
        removeAll in class java.awt.Container
      • addTwoComponents

        public void addTwoComponents​(javax.swing.JComponent leftComponent,
                                     javax.swing.JComponent rightComponent,
                                     boolean fillLeftHandSpace,
                                     boolean fillRightHandSpace)
        Add two components, one is instead of the label on the left.
        Parameters:
        leftComponent - component to add instead of a label
        rightComponent - component to add to the right of the other component
        fillLeftHandSpace - true to make the left component expand to use all space to the left of the other component. False to make it right aligned in the space to the left of the other component, at its preferred size.
        fillRightHandSpace - true to make the right component expand to use all space to the right of the other component. False to make it left aligned in the space to the right of the other component, at its preferred size.
      • setLabelPosition

        public void setLabelPosition​(int anchor)
        Set where the labels (or left component in the case of addTwoComponents(javax.swing.JComponent, javax.swing.JComponent, boolean, boolean) are positioned (normally EAST, WEST or CENTER).

        default GridBagConstraints.EAST

        Only applies to labels added after calling this method.

        Parameters:
        anchor - the position of labels/left hand components. Eg. GridBagConstraints.WEST, GridBagConstraints.CENTER
        See Also:
        GridBagConstraints.anchor
      • setComponentPosition

        public void setComponentPosition​(int anchor)
        Set where the components (or right component in the case of addTwoComponents(javax.swing.JComponent, javax.swing.JComponent, boolean, boolean) are positioned (normally EAST, WEST or CENTER).

        default GridBagConstraints.WEST

        Only applies to components added after calling this method.

        Parameters:
        anchor - the position of right hand components. Eg. GridBagConstraints.WEST, GridBagConstraints.CENTER
        See Also:
        GridBagConstraints.anchor
      • beginBorderedGroup

        public void beginBorderedGroup​(java.lang.String label,
                                       boolean headless)
        Subsequent components will be added inside a bordered sub panel. Multiple calls to this method will result in nested sub panels. Call endBorderedGroup() to close off the current sub panel.
        Parameters:
        label - If this is non-null, the border will have a label on its top-left edge
        headless - if true, the border will not draw its top line (or label if applicable).
        See Also:
        endBorderedGroup()
      • endBorderedGroup

        public void endBorderedGroup()
        If we are adding components to a sub panel (see beginBorderedGroup(String, boolean)), then close off the current sub panel.
      • setHorizontallyCompact

        public void setHorizontallyCompact​(boolean compact)
        Set whether this panel should layout its componets in a visually compact form suitable for displaying in a limited amount of space. The default behaviour is to not be compact.
        Parameters:
        compact - true to cause this panel to layout its componets in a visually compact form suitable for displaying in a limited amount of space.