Set the Size of the Divider in a JSplitPane in Java
Description
The following code shows how to set the Size of the Divider in a JSplitPane.
Example
/*w ww . j a v a 2 s.c o m*/
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JSplitPane;
public class Main {
public static void main(String args[]) {
JFrame frame = new JFrame("Tabbed Pane Sample");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton leftComponent = new JButton("left");
JButton rightComponent= new JButton("right");
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent);
int size = pane.getDividerSize();
size = 1;
pane.setDividerSize(size);
frame.add(pane, BorderLayout.CENTER);
frame.setSize(400, 150);
frame.setVisible(true);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »