开发者

Java layouts, how to max a fixed height pane and one that fills the rest of the screen!

Simply put, I would like to make java do what I want but I can not get my head around the layout manages for anything other that auto resizing to what it feels like doing.

All I would like is a fixed height "footer" and the top "main" area to auto resize in height to whatever the window is.

With the horizontal for both having a min size but no max size.

Is it possible (I know it is but it feels like it isn't atm!)

Please help!

many thanks

Edit: Updated with advice from below:

    public JPanel getPanDescription()
    {
        JPanel mas开发者_如何学编程terPane = new JPanel();
        masterPane.setMaximumSize(new Dimension(999999,400));
        masterPane.setMinimumSize(new Dimension(100,400));
          <snip>
            return masterPane;
    }

this.panDescription = getPanDescription();

this.panPage = new JPanel(new BorderLayout());

this.panPage.add(this.searchPanel, BorderLayout.CENTER);
this.panPage.add(this.panDescription, BorderLayout.PAGE_END);

Works just fine, but depending on the content of panDescription, depends on its size. It still just resizes to the content :S


Use a BorderLayout. Add your footer to the bottom location. Set the max size of the footer to the fixed height you want and a width bigger than your window will ever be.

JPanel mainPanel = new JPanel();
JPanel footerPanel = new JPanel();

this.setLayout(new BorderLayout());
this.add(mainPanel);
this.add(footerPanel, BorderLayout.SOUTH);

footerPanel.setMaximumSize(new Dimension(10000, 100));
footerPanel.setPreferredSize(new Dimension(600, 100));
footerPanel.setMinimumSize(new Dimension(1, 100));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜