java如何使用JSplitPane组件
1个回答
展开全部
package example;import javax.swing.*;import java.awt.Dimension;public class test5 {public static void main(String[] args){JButton b1=new JButton("ok");JButton b2=new JButton("cancel");JSplitPane splitPane=new JSplitPane();//创建一个分割容器类splitPane.setOneTouchExpandable(true);//让分割线显示出箭头splitPane.setContinuousLayout(true);//操作箭头,重绘图形splitPane.setPreferredSize(new Dimension (100,200)); splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);//设置分割线方向splitPane.setLeftComponent(b1);splitPane.setRightComponent(b2);splitPane.setDividerSize(1);splitPane.setDividerLocation(50);//设置分割线位于中央JFrame frame=new JFrame ("test window ");frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);frame.setContentPane(splitPane);frame.pack();}}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询