如何使用java Swing在正确的组件上显示我的jframe?

时间:2013-09-10 16:31:37

标签: java swing

private void PersonalInfoJButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                    

    JPanel createUserJPanel =new CreateUserJPanel(user);
    JSplitPane.setRightComponent(createUserJPanel);

}

它向我显示了non-static method cannot be reffered to static component

之类的错误

如何在正确的组件上显示我的jframe?

2 个答案:

答案 0 :(得分:0)

由于setRightComponent()不是static方法,因此建议使用instance创建method

final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setRightComponent(createUserJPanel);

答案 1 :(得分:0)

您需要创建JSplitPane的实例:

JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.setRightComponent(createUserJPanel);