Use to arrange the JSplitPane.HORIZONTAL_SPLIT two left-to-right of the separator pane Component , or use JSplitPane.VERTICAL_SPLIT it to arrange it from top to bottom. Componentthe preferred way to change the size is to call setDividerLocation , which location is the new x or Y position, depending on JSplitPane the direction.
To be Component adjusted to its preferred size, it can be called resetToPreferredSizes .
1. Common construction methods
JSplitPane(): Creates a new that is configured to arrange its subcomponents horizontally, without a continuous layout, using two buttons for the component JSplitPane .
JSplitPane(int newOrientation): Creates a new one that is configured in the specified direction and has no continuous layout JSplitPane .
JSplitPane(int newOrientation, boolean newContinuousLayout): Creates a new one with the specified direction and redraw mode JSplitPane .
2. Common methods
setDividerLocation(double proportionalLocation): Sets the position of the separator bar to JSplitPane a percentage of the size.
setDividerLocation(int location): Sets the position of the separator bar.
setContinuousLayout(boolean newContinuousLayout): Sets the continuousLayout value of the property, in which the user is expected to cause the subassembly to be continuously re-displayed and layout subcomponents, this value must be true .
setDividerSize(int newSize): Sets the size of the separator bar.
getDividerLocation(): Returns the last value passed to setDividerLocation .
getDividerSize(): Returns the size of the separator bar.
setOneTouchExpandable(boolean newValue): Set oneTouchExpandable The value of the property so that JSplitPane a UI widget is available on the divider to quickly expand/collapse the separator bar, which must be true .
3. Example
Import Java.awt.borderlayout;import javax.swing.jframe;import javax.swing.jlabel;import Javax.swing.JSplitPane; public class Jsplitpanedemo extends JFrame {private static final long Serialversionuid = -3418853823231348095l;public JSPL Itpanedemo () {settitle ("split panel"); SetBounds (+, +, 375); Setdefaultcloseoperation (Jframe.exit_on_close); JSplitPane Hsplitpane = new JSplitPane (); hsplitpane.setdividerlocation (+); Getcontentpane (). Add (Hsplitpane, Borderlayout.center); Hsplitpane.setleftcomponent (New JLabel ("1")); JSplitPane Vsplitpane = new JSplitPane (jsplitpane.vertical_split); Vsplitpane.setleftcomponent (New JLabel ("2")); Vsplitpane.setrightcomponent (New JLabel ("3")); Vsplitpane.setdividerlocation (+); vsplitpane.setdividersize (8); Vsplitpane.setonetouchexpandable (True); Vsplitpane.setcontinuouslayout (true); Hsplitpane.setrightcomponent ( Vsplitpane);} public static void Main (string[] args) {//TODO auto-generated method Stubjsplitpanedemo instance = new Jsplitpanedemo (); I Nstance.setviSible (True);}} 4. Results
JSplitPane use of Java Swing components