Frage

Im' working on a computer science project, and I'm having some issues with borderlayout: that is my configuration (simplified)

public class MainPanel extends JPanel{
    JSplitPane Pcenter;
    JPanel PEnd;

    public MainPanel(Container dad){
        JTable myTable=new JTable(), anotherTable=new JTable();

        JSplitPane left=new JSplitPane();
        left.setTopComponent(new JScrollPane (myTable));
        left.setBottomComponeny(new JScrollPane(anotherTable));
        left.setOrientation(JSplitPane.VERTICAL_SPLIT);

        this.setLayout(new BorderLayout());
        Pcenter=new JSplitPane();
        PEnd=new JPanel();

        pend.add(new JButton("Store"));
        Pcenter.setLeftComponent(left);
        Pcenter.setRightComponent(new JScrollpane(new JLabel("right")));

        this.add(Pcenter,BorderLayout.CENTER);
        this.add(PPnd,BorderLayout.PAGE_END);
        //EDIT:
        PEnd.add(new JLabel("goofy"));
    }
}

Now, my project is different, but this is my configuration

as I run the main (a jframe whith a JTabbed with this attached as a tab) it shows me only the the center and not the end one. But if I attach PEnd at the beginning it's sown as it have to.

EDIT 14-3-14 I dug into my code and I've seen that te problem is generated by the myTable's scrollpane so removing it will make PEnd shown but mytable represents itself in an horrible way

War es hilfreich?

Lösung

PEnd, the panel you are adding at the PAGE_END has nothing added to it so there is nothing to show, and has size 0.

Maybe with the line

pend.add(new JButton("Store"));

you meant

PEnd.add(new JButton("Store"));

As a side note, your variable names should start in lower case to follow standard Java style, to differenciate them from classes.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top