This article shares with you how to use the Swing split pane control JSplitPane for your reference. The specific content is as follows
package day1115;import javax.swing.*;import java.awt.Color;public class Test3 {public static void main(String[] args){ JFrame frame=new JFrame ("test window "); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); JPanel j1= new JPanel(); JPanel j2= new JPanel(); j1.setBackground(Color.red); j2.setBackground(Color.green); JSplitPane splitPane=new JSplitPane();//Create a split container class splitPane.setOneTouchExpandable(true);//Let the split line display arrow splitPane.setContinuousLayout(true);//Operate the arrow and redraw the graph splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);//Set the vertical distribution of the split line direction spli tPane.setLeftComponent(j1);//Set the component splitPane.setRightComponent(j2);//Set the component splitPane.setDividerSize(1);//Set the size of the split line splitPane.setDividerLocation(50);//Set the split line is located in the center frame.setContentPane(splitPane); //frame.pack(), the function of this function is to determine the optimal size of the frame based on the layout in the window and the preferredSize of the component. frame.pack();}}Reproduction image:
Move split line:
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.