java JSplitPane应用实例

package test1;

import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.*;

public class JSplitPaneDemo extends JFrame {
  JPanel jPanel1 = new JPanel();
  JPanel jPanel2 = new JPanel();
  JPanel jPanel3 = new JPanel();
  JPanel jPanel4 = new JPanel();
  BorderLayout borderLayout1 = new BorderLayout();
  JSplitPane jSplitPane1 = new JSplitPane();
  BorderLayout borderLayout2 = new BorderLayout();
  JSplitPane jSplitPane2 = new JSplitPane();
  XYLayout xYLayout1 = new XYLayout();
  JButton jButton1 = new JButton();
  XYLayout xYLayout2 = new XYLayout();
  XYLayout xYLayout3 = new XYLayout();
  JCheckBox jCheckBox1 = new JCheckBox();
  JTextField jTextField1 = new JTextField();
  public static void main(String[] args) {
    JSplitPaneDemo demo = new JSplitPaneDemo();
//    JButton button = new JButton("button");
//    JLabel label = new JLabel("label");
//
//    JSplitPane splitPane = new JSplitPane();
//    splitPane.setOneTouchExpandable(true); //是该分隔面板的分隔条显示出箭头
//    splitPane.setContinuousLayout(true);
//    splitPane.setPreferredSize(new Dimension(320, 320)); //设置大小
//    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
//    //splitPane.setLeftComponent(button); //same as: splitPane.setTopComponent(button);
//    splitPane.add(button,0);
//    splitPane.setRightComponent(label); //same as: splitPane.setBottomComponent(label);
//    splitPane.setDividerSize(6); //设置分隔条的粗细
//    splitPane.setDividerLocation(200); //设置分隔条的位置,基于setPreferredSize方法中的值,
//    //此处为200/500,大概在中间靠左
//
//    JFrame frame = new JFrame("JSplitPanelDemo");
//    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//    frame.setVisible(true);
//    frame.setContentPane(splitPane);
//    frame.pack(); //此方法必须在加载splitPane之后调用
  }

  public JSplitPaneDemo() {
    try {
      jbInit();
      this.setSize(320,320);
      this.show();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  private void jbInit() throws Exception {
    this.getContentPane().setLayout(borderLayout1);
    jPanel1.setLayout(borderLayout2);
    jSplitPane1.setOrientation(JSplitPane.VERTICAL_SPLIT);
    jPanel4.setLayout(xYLayout2);
    jPanel3.setLayout(xYLayout3);
    jPanel2.setLayout(xYLayout1);
    jButton1.setText("jButton1");
    jCheckBox1.setText("jCheckBox1");
    jTextField1.setText("jTextField1");
    this.getContentPane().add(jPanel1,  BorderLayout.CENTER);
    jPanel1.add(jSplitPane1, BorderLayout.CENTER);
    jSplitPane1.add(jSplitPane2, JSplitPane.RIGHT);
    jSplitPane1.setOneTouchExpandable(true);
    jSplitPane1.setDividerLocation(100);
    jSplitPane2.setOneTouchExpandable(true);
    jSplitPane2.setDividerLocation(100);
    jSplitPane1.setContinuousLayout(false);
    jSplitPane2.setContinuousLayout(false);
    jSplitPane1.add(jPanel2,JSplitPane.TOP);
    jPanel2.add(jButton1,  new XYConstraints(33, 21, -1, -1));
    jSplitPane2.add(jPanel4,JSplitPane.LEFT);
    jPanel4.add(jCheckBox1,  new XYConstraints(14, 50, -1, -1));
    jSplitPane2.add(jPanel3,JSplitPane.RIGHT);
    jPanel3.add(jTextField1,   new XYConstraints(66, 55, -1, -1));
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值