//
首先,在JFrame 显示出来的时候,为什么bottom.setDividerLocation(0.5);
显示不出来正确的位置,当点击按钮
JButton b=new JButton( "real divider ");
就能正确显示分割线的位置
代码如下:
//
package swingTest;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
* <p> Title: </p>
* <p> Description: </p>
* <p> Copyright: Copyright (c) 2006 </p>
* <p> Company: </p>
* @author not attributable
* @version 1.0
*/
public class ScrollPaneTest {
public static void main(String[] arg){
JFrame f=new JFrame();
f.setSize(600,500);
f.setLocation(250,250);
Container c= f.getContentPane();
c.setLayout(new BorderLayout());
final JSplitPane left=new JSplitPane(JSplitPane.VERTICAL_SPLIT,new JPanel(),new JPanel());
JPanel p1=new JPanel();
JButton b=new JButton( "real divider ");
p1.add(b);
JPanel p2=new JPanel();
JPanel p3=new JPanel();
final JSplitPane bottom=new JSplitPane(JSplitPane.VERTICAL_SPLIT,p2,p3);
final JSplitPane right=new JSplitPane(JSplitPane.VERTICAL_SPLIT,p1,bottom);
JPanel leftPanel=new JPanel(new BorderLayout());
// leftPanel.add(left,BorderLayout.CENTER);
final JSplitPane top=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,left,right);
c.add(top,BorderLayout.CENTER);
f.setVisible(true);
top.setDividerLocation(0.7);
right.setDividerLocation(0.3);
bottom.setDividerLocation(0.5);
left.setDividerLocation(0.8);
b.addActionListener(new ActionListener(){