JSplitPane

JSplitPaneDemo.java
01 package cn.rolia.learning.swing;
02 import javax.swing.*;
03 import java.awt.Dimension;
04 public class JSplitPaneDemo
05 {
06  public static void main (String[] args)
07  {
08   
09   JButton button = new JButton ("button");
10   JLabel label = new JLabel ("label");
11   
12   JSplitPane splitPane = new JSplitPane ();
13   splitPane.setOneTouchExpandable (true);//是该分隔面板的分隔条显示出箭头
14   splitPane.setContinuousLayout (true);
15   splitPane.setPreferredSize (new Dimension (500,600));//设置大小
16   splitPane.setOrientation (JSplitPane.HORIZONTAL_SPLIT);
17   splitPane.setLeftComponent (button);//same as: splitPane.setTopComponent(button);
18   splitPane.setRightComponent (label);//same as: splitPane.setBottomComponent(label);
19   splitPane.setDividerSize (5);//设置分隔条的粗细
20   splitPane.setDividerLocation(200);//设置分隔条的位置,基于setPreferredSize方法中的值,
21            //此处为200/500,大概在中间靠左
22 
23   JFrame frame = new JFrame ("JSplitPanelDemo");
24   frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
25   frame.setVisible (true);
26   frame.setContentPane (splitPane);
27   frame.pack ();//此方法必须在加载splitPane之后调用
28  }
29 }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值