📄 jsplitpane.java
字号:
public Component getLeftComponent() { return leftComponent; } /** * This method returns the maximum divider location. This method is passed * to the UI. * * @return DOCUMENT ME! */ public int getMaximumDividerLocation() { if (ui != null) return ((SplitPaneUI) ui).getMaximumDividerLocation(this); else return -1; } /** * This method returns the minimum divider location. This method is passed * to the UI. * * @return The minimum divider location. */ public int getMinimumDividerLocation() { if (ui != null) return ((SplitPaneUI) ui).getMinimumDividerLocation(this); else return -1; } /** * This method returns the orientation that the JSplitPane is using. * * @return The current orientation. */ public int getOrientation() { return orientation; } /** * This method returns the current resize weight. * * @return The current resize weight. */ public double getResizeWeight() { return resizeWeight; } /** * This method returns the right component. * * @return The right component. */ public Component getRightComponent() { return rightComponent; } /** * This method returns the top component. * * @return The top component. */ public Component getTopComponent() { return leftComponent; } /** * This method returns the UI. * * @return The UI. */ public SplitPaneUI getUI() { return (SplitPaneUI) ui; } /** * This method returns true if the JSplitPane is using a continuousLayout. * * @return True if using a continuousLayout. */ public boolean isContinuousLayout() { return continuousLayout; } /** * This method returns true if the divider has one touch expandable buttons. * * @return True if one touch expandable is used. */ public boolean isOneTouchExpandable() { return oneTouchExpandable; } /** * This method returns true. * * @return true. */ public boolean isValidateRoot() { return true; } /** * This method overrides JComponent's paintChildren so the UI can be * messaged when the children have finished painting. * * @param g The Graphics object to paint with. */ protected void paintChildren(Graphics g) { super.paintChildren(g); if (ui != null) ((SplitPaneUI) ui).finishedPaintingChildren(this, g); } /** * This method returns a String that describes this JSplitPane. The string * is primarily used for debugging purposes. * * @return A String used for debugging purposes. */ protected String paramString() { return "JSplitPane"; } /** * This method removes the given component from the JSplitPane. * * @param component The Component to remove. */ public void remove(Component component) { if (component == leftComponent) leftComponent = null; else if (component == rightComponent) rightComponent = null; super.remove(component); } /** * This method removes the component at the given index. * * @param index The index of the component to remove. */ public void remove(int index) { Component component = getComponent(index); if (component == leftComponent) leftComponent = null; else if (component == rightComponent) rightComponent = null; super.remove(index); } /** * This method removes all components from the JSplitPane. */ public void removeAll() { leftComponent = null; rightComponent = null; super.removeAll(); } /** * This method resets all children of the JSplitPane to their preferred * sizes. */ public void resetToPreferredSizes() { if (ui != null) ((SplitPaneUI) ui).resetToPreferredSizes(this); } /** * This method sets the bottom component. * * @param comp The Component to be placed at the bottom. */ public void setBottomComponent(Component comp) { if (comp != null) add(comp, BOTTOM); else add(new JButton("right button"), BOTTOM); } /** * This method sets the layout mode for the JSplitPane. * * @param newContinuousLayout Whether the JSplitPane is in continuousLayout * mode. */ public void setContinuousLayout(boolean newContinuousLayout) { if (newContinuousLayout != continuousLayout) { boolean oldValue = continuousLayout; continuousLayout = newContinuousLayout; firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue, continuousLayout); } } /** * This method sets the location of the divider. A value of 0 sets the * divider to the farthest left. A value of 1 sets the divider to the * farthest right. * * @param proportionalLocation A double that describes the location of the * divider. * * @throws IllegalArgumentException DOCUMENT ME! */ public void setDividerLocation(double proportionalLocation) { if (proportionalLocation > 1 || proportionalLocation < 0) throw new IllegalArgumentException ("proportion has to be between 0 and 1."); int max = (orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight(); setDividerLocation((int) (proportionalLocation * max)); } /** * This method sets the location of the divider. * * @param location The location of the divider. */ public void setDividerLocation(int location) { if (ui != null && location != getDividerLocation()) { int oldLocation = getDividerLocation(); ((SplitPaneUI) ui).setDividerLocation(this, location); firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location); } } /** * This method sets the size of the divider. * * @param newSize The size of the divider. */ public void setDividerSize(int newSize) { if (newSize != dividerSize) { int oldSize = dividerSize; dividerSize = newSize; firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize); } } // This doesn't appear to do anything when set from user side. // so it probably is only used from the UI side to change the // lastDividerLocation var. /** * This method sets the last location of the divider. * * @param newLastLocation The last location of the divider. */ public void setLastDividerLocation(int newLastLocation) { if (newLastLocation != lastDividerLocation) { int oldValue = lastDividerLocation; lastDividerLocation = newLastLocation; firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue, lastDividerLocation); } } /** * This method sets the left component. * * @param comp The left component. */ public void setLeftComponent(Component comp) { if (comp != null) add(comp, LEFT); else remove (leftComponent); } /** * This method sets whether the divider has one touch expandable buttons. * The one touch expandable buttons can expand the size of either component * to the maximum allowed size. * * @param newValue Whether the divider will have one touch expandable * buttons. */ public void setOneTouchExpandable(boolean newValue) { if (newValue != oneTouchExpandable) { boolean oldValue = oneTouchExpandable; oneTouchExpandable = newValue; firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue, oneTouchExpandable); } } /** * This method sets the orientation of the JSplitPane. * * @param orientation The orientation of the JSplitPane. * * @throws IllegalArgumentException DOCUMENT ME! */ public void setOrientation(int orientation) { if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT) throw new IllegalArgumentException ("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT"); if (orientation != this.orientation) { int oldOrientation = this.orientation; this.orientation = orientation; firePropertyChange(ORIENTATION_PROPERTY, oldOrientation, this.orientation); } } /** * This method determines how extra space will be distributed among the left * and right components. A value of 0 will allocate all extra space to the * right component. A value of 1 indicates that all extra space will go to * the left component. A value in between 1 and 0 will split the space * accordingly. * * @param value The resize weight. */ public void setResizeWeight(double value) { resizeWeight = value; } /** * This method sets the right component. * * @param comp The right component. */ public void setRightComponent(Component comp) { if (comp != null) add(comp, RIGHT); else remove (rightComponent); } /** * This method sets the top component. * * @param comp The top component. */ public void setTopComponent(Component comp) { if (comp != null) add(comp, TOP); else add(new JButton("left button"), TOP); } /** * This method sets the UI used by the JSplitPane. * * @param ui The UI to use. */ public void setUI(SplitPaneUI ui) { super.setUI(ui); } /** * This method resets the UI to the one specified by the current Look and * Feel. */ public void updateUI() { setUI((SplitPaneUI) UIManager.getUI(this)); invalidate(); repaint(); } /** * This method returns a string identifier to determine which UI class it * needs. * * @return A string that identifies it's UI class. */ public String getUIClassID() { return "SplitPaneUI"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -