正文

JSplitPane用法2005-09-18 17:23:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/hurongliang/4946.html

分享到:

import javax.swing.*;import java.awt.Dimension;public class JSplitPaneDemo{ public static void main (String[] args) {    JButton button = new JButton ("button");  JLabel label = new JLabel ("label");    JSplitPane splitPane = new JSplitPane ();  splitPane.setOneTouchExpandable (true);//是该分隔面板的分隔条显示出箭头  splitPane.setContinuousLayout (true);  splitPane.setPreferredSize (new Dimension (500,600));//设置大小  splitPane.setOrientation (JSplitPane.HORIZONTAL_SPLIT);  splitPane.setLeftComponent (button);//same as: splitPane.setTopComponent(button);  splitPane.setRightComponent (label);//same as: splitPane.setBottomComponent(label);  splitPane.setDividerSize (5);//设置分隔条的粗细  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之后调用 }}

阅读(7621) | 评论(3)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册