Class JideSplitPane

All Implemented Interfaces:
ComponentListener, ContainerListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class JideSplitPane extends JPanel implements ContainerListener, ComponentListener, Accessible
JideSplitPane is used to divide multiple Components.

These Components in a split pane can be aligned left to right using JideSplitPane.HORIZONTAL_SPLIT, or top to bottom using JideSplitPane.VERTICAL_SPLIT.

See Also:
  • Field Details

    • NON_CONTINUOUS_DIVIDER

      protected static final String NON_CONTINUOUS_DIVIDER
      The divider used for non-continuous layout is added to the split pane with this object.
      See Also:
    • VERTICAL_SPLIT

      public static final int VERTICAL_SPLIT
      Vertical split indicates the Components are split along the y axis. For example the two or more Components will be split one on top of the other.
      See Also:
    • HORIZONTAL_SPLIT

      public static final int HORIZONTAL_SPLIT
      Horizontal split indicates the Components are split along the x axis. For example the two or more Components will be split one to the left of the other.
      See Also:
    • ORIENTATION_PROPERTY

      public static final String ORIENTATION_PROPERTY
      Bound property name for orientation (horizontal or vertical).
      See Also:
    • DIVIDER_SIZE_PROPERTY

      public static final String DIVIDER_SIZE_PROPERTY
      Bound property name for border size.
      See Also:
    • PROPERTY_DIVIDER_LOCATION

      public static final String PROPERTY_DIVIDER_LOCATION
      Bound property name for border size.
      See Also:
    • CONTINUOUS_LAYOUT_PROPERTY

      public static final String CONTINUOUS_LAYOUT_PROPERTY
      Bound property name for continuousLayout.
      See Also:
    • GRIPPER_PROPERTY

      public static final String GRIPPER_PROPERTY
      Bound property name for gripper.
      See Also:
    • PROPORTIONAL_LAYOUT_PROPERTY

      public static final String PROPORTIONAL_LAYOUT_PROPERTY
      Bound property name for proportional layout.
      See Also:
    • PROPORTIONS_PROPERTY

      public static final String PROPORTIONS_PROPERTY
      Bound property name for the proportions used in the layout.
      See Also:
    • PROPERTY_HEAVYWEIGHT_COMPONENT_ENABLED

      public static final String PROPERTY_HEAVYWEIGHT_COMPONENT_ENABLED
      See Also:
    • _windowDeactivatedListener

      public WindowAdapter _windowDeactivatedListener
    • ONE_TOUCH_EXPANDABLE_PROPERTY

      public static final String ONE_TOUCH_EXPANDABLE_PROPERTY
      Bound property for oneTouchExpandable.
      See Also:
  • Constructor Details

    • JideSplitPane

      public JideSplitPane()
      Creates a new JideSplitPane configured to arrange the child components side-by-side horizontally.
    • JideSplitPane

      public JideSplitPane(int newOrientation)
      Creates a new JideSplitPane configured with the specified orientation.
      Parameters:
      newOrientation - JideSplitPane.HORIZONTAL_SPLIT or JideSplitPane.VERTICAL_SPLIT
      Throws:
      IllegalArgumentException - if orientation is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT.
  • Method Details

    • getDividerStepSize

      public int getDividerStepSize()
      Get the step size while dragging the divider.

      The default value of the step size is 0, which means no constraints on the dragging position

      Returns:
      the step size.
    • setDividerStepSize

      public void setDividerStepSize(int dividerStepSize)
      Set the step size while dragging the divider.

      The step size cannot be negative.

      Parameters:
      dividerStepSize - the step size
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JPanel
    • setDividerSize

      public void setDividerSize(int newSize)
      Sets the size of the divider.
      Parameters:
      newSize - an integer giving the size of the divider in pixels
    • getDividerSize

      public int getDividerSize()
      Returns the size of the divider.
      Returns:
      an integer giving the size of the divider in pixels
    • insertPane

      public Component insertPane(Component pane, int index)
      Inserts the specified pane to this container at the given position. Note: Divider is not counted.
      Parameters:
      pane - the pane to be added
      index - the position at which to insert the component.
      Returns:
      the component pane
    • insertPane

      public Component insertPane(Component pane, Object constraint, int index)
      Inserts the specified pane to this container at the given position. Note: Divider is not counted.
      Parameters:
      pane - the pane to be added
      constraint - an object expressing layout constraints for this component
      index - the position at which to insert the component.
      Returns:
      the component pane
    • addPane

      public Component addPane(Component pane)
      Adds the specified pane to this container at the end.
      Parameters:
      pane - the pane to be added
      Returns:
      the pane pane
    • removePane

      public void removePane(Component pane)
      Removes the pane, specified by index, from this container.
      Parameters:
      pane - the pane to be removed.
    • setPaneAt

      public void setPaneAt(Component pane, int index)
      Replaces the pane at the position specified by index.
      Parameters:
      pane - new pane
      index - position
    • setPaneAt

      public void setPaneAt(Component pane, Object constraint, int index)
      Replaces the pane at the position specified by index.
      Parameters:
      pane - new pane
      constraint - an object expressing layout constraints for this component
      index - position
    • removePane

      public void removePane(int index)
      Removes the pane, specified by index, from this container.
      Parameters:
      index - the index of the component to be removed.
    • setOrientation

      public void setOrientation(int orientation)
      Sets the orientation, or how the splitter is divided. The options are:
      • JideSplitPane.VERTICAL_SPLIT (above/below orientation of components)
      • JideSplitPane.HORIZONTAL_SPLIT (left/right orientation of components)
      Parameters:
      orientation - an integer specifying the orientation
      Throws:
      IllegalArgumentException - if orientation is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT.
    • getOrientation

      public int getOrientation()
      Returns the orientation.
      Returns:
      an integer giving the orientation
      See Also:
    • resetToPreferredSizes

      public void resetToPreferredSizes()
      Lays out the JideSplitPane layout based on the preferred size children components, or based on the proportions if proportional layout is on. This will likely result in changing the divider location.
    • setProportionalLayout

      public void setProportionalLayout(boolean proportionalLayout)
      Sets this split pane to lay its constituents out proportionally if the given flag is true, or by preferred sizes otherwise.
      Parameters:
      proportionalLayout - true or false.
    • isProportionalLayout

      public boolean isProportionalLayout()
      Returns the proportional layout flag.
      Returns:
      true or false.
    • setProportions

      public void setProportions(double[] proportions)
      Sets the proportions to use in laying out this split pane's children. Only applicable when isProportionalLayout() is true; calling it when false will throw an exception. The given array must either be null, or have one fewer slots than there are contained panes. Each item in the array (if not null) must be a number between 0 and 1, and the sum of all of them must be no more than 1.
      Parameters:
      proportions - the proportions of all the panes.
    • getProportions

      public double[] getProportions()
      Returns the current array of proportions used for proportional layout, or null if none has been established via setProportions(double[]) or via user action.
      Returns:
      the proportions.
    • setInitiallyEven

      public void setInitiallyEven(boolean initiallyEven)
      Sets the flag telling whether to do even proportions for the initial proportional layout, in the absence of explicit proportions.
      Parameters:
      initiallyEven - true or false.
    • isInitiallyEven

      public boolean isInitiallyEven()
      Returns the flag that tells whether to do even proportions for the initial proportional layout, in the absence of explicit proportions.
      Returns:
      true or false.
    • isValidateRoot

      public boolean isValidateRoot()
      Returns true, so that calls to revalidate on any descendant of this JideSplitPane will cause a request to be queued that will validate the JideSplitPane and all its descendants.
      Overrides:
      isValidateRoot in class JComponent
      Returns:
      true
      See Also:
    • startDragging

      protected void startDragging(JideSplitPaneDivider divider)
      Prepares dragging if it's not continuous layout. If it's continuous layout, do nothing.
      Parameters:
      divider - the divider
    • dragDividerTo

      protected void dragDividerTo(JideSplitPaneDivider divider, int location)
      Drags divider to right location. If it's continuous layout, really drag the divider; if not, only drag the shadow.
      Parameters:
      divider - the divider
      location - new location
    • finishDraggingTo

      protected void finishDraggingTo(JideSplitPaneDivider divider, int location)
      Finishes dragging. If it's not continuous layout, clear up the shadow component.
      Parameters:
      divider - the divider
      location - new location
    • indexOfDivider

      public int indexOfDivider(JideSplitPaneDivider divider)
      Returns the index of the divider. For example, the index of the first divider is 0, the index of the second is 1. Notes: Pane is not counted
      Parameters:
      divider - divider to get index
      Returns:
      index of the divider. -1 if comp doesn't exist in this container
    • indexOfPane

      public int indexOfPane(Component pane)
      Returns the index of the pane. For example, the index of the first pane is 0, the index of the second is 1. Notes: divider is not counted
      Parameters:
      pane - pane to get index
      Returns:
      index of the pane. -1 if comp doesn't exist in this container
    • indexOf

      public int indexOf(Component comp)
      Returns the index of the component.
      Parameters:
      comp - component to get index
      Returns:
      index of the comp. -1 if comp doesn't exist in this container
    • getDividerAt

      public JideSplitPaneDivider getDividerAt(int index)
      Returns the divider at index.
      Parameters:
      index - index
      Returns:
      the divider at the index
    • getPaneAt

      public Component getPaneAt(int index)
      Returns the component at index.
      Parameters:
      index - index
      Returns:
      the component at the index
    • getPaneCount

      public int getPaneCount()
      Gets the count of panes, regardless of dividers.
      Returns:
      the count of panes
    • setDividerLocation

      public void setDividerLocation(JideSplitPaneDivider divider, int location)
      Set the divider location.
      Parameters:
      divider - the divider
      location - new location
    • setDividerLocation

      public void setDividerLocation(int dividerIndex, int location)
      Set the divider location. You can only call this method to set the divider location when the component is rendered on the screen. If the component has never been displayed before, this method call has no effect.
      Parameters:
      dividerIndex - the divider index, starting from 0 for the first divider.
      location - new location
    • getDividerLocation

      public int getDividerLocation(int dividerIndex)
      Get the divider location. You can only get a valid divider location when the component is displayed on the screen. If the component has never been displayed on screen, -1 will be returned.
      Parameters:
      dividerIndex - the divider index
      Returns:
      the location of the divider.
    • componentAdded

      public void componentAdded(ContainerEvent e)
      Invoked when a component has been added to the container. Basically if you add anything which is not divider, a divider will automatically added before or after the component.
      Specified by:
      componentAdded in interface ContainerListener
      Parameters:
      e - ContainerEvent
    • componentRemoved

      public void componentRemoved(ContainerEvent e)
      Invoked when a component has been removed from the container. Basically if you remove anything which is not divider, a divider will automatically deleted before or after the component.
      Specified by:
      componentRemoved in interface ContainerListener
      Parameters:
      e - ContainerEvent
    • componentResized

      public void componentResized(ComponentEvent e)
      Specified by:
      componentResized in interface ComponentListener
    • componentMoved

      public void componentMoved(ComponentEvent e)
      Specified by:
      componentMoved in interface ComponentListener
    • componentShown

      public void componentShown(ComponentEvent e)
      Specified by:
      componentShown in interface ComponentListener
    • componentHidden

      public void componentHidden(ComponentEvent e)
      Specified by:
      componentHidden in interface ComponentListener
    • removeExtraDividers

      protected boolean removeExtraDividers()
      Remove extra divider. One is considered as extra dividers where two dividers are adjacent.
      Returns:
      true if dividers are removed.
    • removeProportion

      protected void removeProportion(int paneIndex)
      Removes the proportion at the given pane index, spreading its value proportionally across the other proportions. If it's the last proportion being removed, sets the proportions to null.
      Parameters:
      paneIndex - the pane index.
    • addExtraDividers

      protected void addExtraDividers()
      Add divider if there are two panes side by side without a divider in between.
    • addProportion

      protected void addProportion(int paneIndex)
      Adds a proportion at the given pane index, taking a proportional amount from each of the existing proportions.
      Parameters:
      paneIndex - the pane index.
    • setVisible

      public void setVisible(boolean aFlag)
      Overrides:
      setVisible in class JComponent
    • setDividersVisible

      protected void setDividersVisible()
      Before this method is call, the panes must be separated by dividers.
    • createSplitPaneDivider

      protected JideSplitPaneDivider createSplitPaneDivider()
    • getPreviousDividerLocation

      protected int getPreviousDividerLocation(JideSplitPaneDivider divider, boolean ignoreVisibility, boolean reversed)
      Get previous divider's, if any, location from current divider. If there is no previous divider, return 0.
      Parameters:
      divider - the divider
      ignoreVisibility - true to not check if the pane is visible.
      reversed - from left to right or reversed.
      Returns:
      the location of previous divider if any
    • getNextDividerLocation

      public int getNextDividerLocation(JideSplitPaneDivider divider, boolean ignoreVisibility, boolean reversed)
      Get previous divider's, if any, location from current divider. If there is no previous divider, return 0.
      Parameters:
      divider - the divider
      ignoreVisibility - true to not check if the pane is visible.
      reversed - from left to right or reversed.
      Returns:
      the location of next divider if any
    • isShowGripper

      public boolean isShowGripper()
      Checks if the gripper is visible.
      Returns:
      true if gripper is visible
    • setShowGripper

      public void setShowGripper(boolean showGripper)
      Sets the visibility of gripper.
      Parameters:
      showGripper - true to show gripper
    • doLayout

      public void doLayout()
      Causes this container to lay out its components. Most programs should not call this method directly, but should invoke the validate method instead.
      Overrides:
      doLayout in class Container
      Since:
      JDK1.1
      See Also:
    • isContinuousLayout

      public boolean isContinuousLayout()
      Determines whether the JSplitPane is set to use a continuous layout.
      Returns:
      true or false.
    • setContinuousLayout

      public void setContinuousLayout(boolean continuousLayout)
      Turn continuous layout on/off.
      Parameters:
      continuousLayout - true or false.
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
      Gets the AccessibleContext associated with this JideSplitPane. For split panes, the AccessibleContext takes the form of an AccessibleJideSplitPane. A new AccessibleJideSplitPane instance is created if necessary.
      Specified by:
      getAccessibleContext in interface Accessible
      Overrides:
      getAccessibleContext in class JPanel
      Returns:
      an AccessibleJideSplitPane that serves as the AccessibleContext of this JideSplitPane
    • isDragResizable

      public boolean isDragResizable()
      Get the flag indicating if dragging the divider could resize the panes.

      By default, the value is true for JideSplitPane. You could set it to false if you don't like it.

      Returns:
      the flag.
    • setDragResizable

      public void setDragResizable(boolean dragResizable)
      Set the flag indicating if dragging the divider could resize the panes.
      Parameters:
      dragResizable - the flag
    • isHeavyweightComponentEnabled

      public boolean isHeavyweightComponentEnabled()
      Returns:
      true if the heavyweight component is enabled.
    • setHeavyweightComponentEnabled

      public void setHeavyweightComponentEnabled(boolean heavyweightComponentEnabled)
      Enables heavyweight components. The difference is the divider. If true, the divider will be heavyweight divider. Otherwise it will use lightweight divider.
      Parameters:
      heavyweightComponentEnabled - true to enable the usage of heavyweight components.
    • setOneTouchExpandable

      public void setOneTouchExpandable(boolean oneTouchExpandable)
      Sets the value of the oneTouchExpandable property. If true, the JSplitPane will display a UI widget on the divider to quickly expand/collapse the divider.

      The default value of this property is false.

      Please note: Some look and feels might not support one-touch expanding; they will ignore this property.
      Parameters:
      oneTouchExpandable - true to specify that the split pane should provide a collapse/expand widget
      See Also:
    • isOneTouchExpandable

      public boolean isOneTouchExpandable()
      Returns whether one-touch expand/collapse is on.
      Returns:
      the value of the oneTouchExpandable property
      See Also:
    • setLeftOneTouchButtonImageIcon

      public void setLeftOneTouchButtonImageIcon(ImageIcon leftButtonImageIcon)
      Sets the left button's image icon. By default, the button has a width of 5 pixels and a height of 10 pixel in HORIZONTAL_SPLIT mode (and a width of 10 pixels and a height of 5 pixel in VERTICAL_SPLIT mode) -- this should be considered when assigning its imageIcon.
      Parameters:
      leftButtonImageIcon - the image to be displayed on the left one-touch button
    • getLeftOneTouchButtonImageIcon

      public ImageIcon getLeftOneTouchButtonImageIcon()
      Gets the left button's image icon.
      Returns:
      the imageIcon used displayed on the left one-touch button
    • setRightOneTouchButtonImageIcon

      public void setRightOneTouchButtonImageIcon(ImageIcon rightButtonImageIcon)
      Sets the right button's image icon. By default, the button has a width of 5 pixels and a height of 10 pixel in HORIZONTAL_SPLIT mode (and a width of 10 pixels and a height of 5 pixel in VERTICAL_SPLIT mode) -- this should be considered when assigning its imageIcon.
      Parameters:
      rightButtonImageIcon - the image to be displayed on the right one-touch button
    • getRightOneTouchButtonImageIcon

      public ImageIcon getRightOneTouchButtonImageIcon()
      Gets the right button's image icon.
      Returns:
      the imageIcon used displayed on the left one-touch button
    • setDividerLocations

      public void setDividerLocations(int[] locations)
      Sets the divider locations.
      Parameters:
      locations - the new divider locations.
    • getDividerLocations

      public int[] getDividerLocations()
      Gets the divider locations.
      Returns:
      the divider locations.