Re: JSplitPane class of java
Hi,
SplitPane is used to divide two (and only two) Components. The two Components are graphically divided based on the look and feel implementation, and the two Components can then be interactively resized by the user. The two Components in a split pane can be aligned left to right using JSplitPane.HORIZONTAL_SPLIT, or top to bottom using JSplitPane.VERTICAL_SPLIT. The preferred way to change the size of the Components is to invoke setDividerLocation where location is either the new x or y position, depending on the orientation of the JSplitPane.
Re: JSplitPane class of java
Please refer following example of JSplitPane class of java:
Code:
import javax.swing.JSplitPane;
public class JSplitPaneDemo{
public static void main(String[] a) {
int HORIZSPLT = JSplitPane.HORIZONTAL_SPLIT;
int VERTSPLT = JSplitPane.VERTICAL_SPLIT;
boolean continuousLayout = true;
JLabel labelv1 = new JLabel("a");
JLabel labelv2 = new JLabel("b");
JLabel labelv3 = new JLabel("c");
JSplitPane splitPane01 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2);
splitPane01.setOneTouchExpandable(true);
splitPane01.setDividerSize(2);
splitPane01.setDividerLocation(0.5);
JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane01, label3);
splitPane2.setOneTouchExpandable(true);
splitPane2.setDividerLocation(0.4);
splitPane2.setDividerSize(2);
JFrame frame07 = new JFrame();
frame07.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame07.add(splitPane2);
frame07.pack();
frame07.setVisible(true);
}
}
Re: JSplitPane class of java
Hello friend,
Following are some constructors of JSplitPane class along with different parameters:
- JSplitPane(int newOrn, Component newLeftComp, Component newRightComp)
- JSplitPane(int newOrn, boolean newContinuousLyt, Component newLeftComp, Component newRightComp)
- JSplitPane(int newOrn, boolean newContinuousLyt)
- JSplitPane(int newOrn)
- JSplitPane()
Re: JSplitPane class of java
Following part of java program will demonstrate you the use of JSplitPane class of java, please review it carefully:
Code:
public JSplitPane()
JSplitPane splitPn = new JSplitPane();
public JSplitPane(int Orn)
JSplitPane splitPn = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
public JSplitPane(int Orn, Component newLeftComponent, Component newRightComponent)
JComponent topComponent = new JButton("Top Button");
JComponent bottomComponent = new JButton("Bottom Button");
JSplitPane splitPn = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topComponent, bottomComponent);
public JSplitPane(int Orn, boolean newContinuousLayout)
JSplitPane splitPn = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true);
public JSplitPane(int Orn, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent)
JSplitPane splitPn = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, topComponent, bottomComponent);
Re: JSplitPane class of java
Hi friend,
To make use use of JSplitPane class, you need to be aware about following important methods of this class:
- setUI(SplitPaneUI sui)
- setTopComponent(Component compn)
- setRightComponent(Component compn)
- setResizeWeight(double val)
- setOrientation(int ortn)
- setOneTouchExpandable(boolean newVal)