import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SimpleSplitPane extends JFrame { static String markus1 = "Här börjar glädjebudet om Jesus Kristus, Guds son. " + "Som det står skrivet hos profeten Jesaja: Se, jag sänder min budbärare före dig, " + "han ska bereda vägen för dig. En röst ropar i öknen: Bana väg för Herren, " + "gör hans stigar raka."; public SimpleSplitPane() { super("Simple SplitPane Frame"); setSize(450, 200); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JTextArea jt1 = new JTextArea(markus1); JTextArea jt2 = new JTextArea(markus1); // Make sure our text boxes do line wrapping and have reasonable // minimum sizes. jt1.setLineWrap(true); jt2.setLineWrap(true); //If minimumSize is not set for a textArea it will automatically //be set to the initial size when first displayed. Since //no of the components is allowed to become smaller then its //minimum size this would cause the divider to be stuck. jt1.setMinimumSize(new Dimension(150, 150)); jt2.setMinimumSize(new Dimension(150, 150)); //The first component must have a preferredSize, or //it will occupy the whole JSplitPane. jt1.setPreferredSize(new Dimension(250, 200)); JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jt1, jt2); //Display the quick move components on the divider. sp.setOneTouchExpandable(true); getContentPane().add(sp, BorderLayout.CENTER); } public static void main(String args[]) { SimpleSplitPane ssb = new SimpleSplitPane(); ssb.setVisible(true); } }