JSplitPane没有显示出来

时间:2016-03-10 09:43:57

标签: java swing jsplitpane

我遇到了JSplitPane问题,我将组件设置为JSplitPane,但没有显示任何内容。 这是代码:

/**__COMPONENT OBJECTS__**/
    JFrame frame = new JFrame();
    JPanel leftPane = new JPanel();
    JPanel rightPane = new JPanel();
    JTextArea textArea = new JTextArea();
    JButton button = new JButton("LOL");
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    /**__SPLITPANE-PROPS__**/
    splitPane.setLeftComponent(leftPane);
    splitPane.setRightComponent(rightPane);
    splitPane.setLayout(null);
    splitPane.setSize(frame.getWidth(), frame.getHeight() - menuBar.getHeight());
    splitPane.setVisible(true);
    splitPane.setLocation(0,menuBar.getHeight());
    int ht = splitPane.getHeight();

    /**__RIGHTPANE-PROPS__**/
    rightPane.add(textArea);
    rightPane.setSize(500, ht);
    rightPane.setVisible(true);

    /**__LEFTPANE-PROPS__**/
    leftPane.add(button);
    leftPane.setSize(100, ht);
    leftPane.setVisible(true);

    /**__FRAME-PROPS__**/
    frame.setJMenuBar(menuBar);
    frame.add(splitPane);
    frame.setLayout(new GridLayout());
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setSize(500,400);
    frame.setVisible(true);

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:2)

我做了一些修改工作正常

Last_Authorised_Range(Range_Event_Id)

工作正常

答案 1 :(得分:0)

没关系,问题如下: 我将JSplitPanel设置为JFrame大小,但JFrame大小设置在方法的末尾...... -.-