javacodex.com
Java Examples
Java Examples
memu home questions

JSplitPane

A JSplitPane is a splitter that can be used to split space between two components. The splitter bar can be displayed horizontally or vertically. When the available space is less than the space needed to display the two components, the user can move the splitter bar up/down or left/right, so one component gets more space than the other. If there is enough space, both components can be shown fully.

Source: (JSplitPaneExample.java)

import javax.swing.*;
import java.awt.*;
 
public class JSplitPaneExample {
  public static void main(String [] args) {
 
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame("JSplitPane Example");
    frame.setSize(240,100);
 
    JSplitPane split = new JSplitPane();		 
 
    JLabel label1 = new JLabel("Left side content");
    JLabel label2 = new JLabel("Right side content");
 
    split.setLeftComponent(label1);
    split.setRightComponent(label2);
 
    frame.add(split);	
    frame.setVisible(true);			
  }
}
 

Output:

$ java JSplitPaneExample
Output



Contact: javacodex@yahoo.com