我的JTabbedPane放在JPanel的JSplitPane中,就像这样,但是我不希望它这么小:



我希望它看起来像这样:



我怎么做?

这是我的代码:

Tabbed_Tables.java

public void setupWidow(){
        JPanel left = new JPanel();
        JPanel right = new JPanel();

        JTabbedPane EntryTabs =  new JTabbedPane();
        JTabbedPane ViewTabs =  new JTabbedPane();
        EntryTabs.addTab("Form Entry", new FormEntry());
        EntryTabs.setOpaque(true);
        EntryTabs.addTab("Table Entry", new TableEntry());
        //EntryTabs.setSize(new Dimension(500,500));
        //ViewTabs.setSize(new Dimension(200,200));
        ViewTabs.add("Help Window", new HelpWindow());


        left.add(EntryTabs);
        right.add(ViewTabs);

        JSplitPane splitPane= new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,left, right);
        splitPane.setSize(new Dimension(pane.getWidth(),pane.getHeight()));
        //((JFrame) pane).setContentPane(splitPane);
        pane.add(splitPane,BorderLayout.CENTER);
        //this.setSize(500, 500);


        this.setVisible(true);
        this.revalidate();
    }

最佳答案

JTabbedPane直接添加到JSplitPane

JSplitPane splitPane= new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true, EntryTabs, ViewTabs);


或将leftright的布局管理器更改为BorderLayout

JPanel left = new JPanel(new BorderLayout());
JPanel right = new JPanel(new BorderLayout());


有关更多详细信息,请参见How to Use BorderLayout

关于java - 如何在JSplitPane中获取JTabbedPane来填充整个窗口?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30724501/

10-13 09:32