Making a JPanel manually resizable

前端 未结 4 2042
我寻月下人不归
我寻月下人不归 2020-12-31 08:10

I have a JFrame with BorderLayout as the layout manager.

In the south border, I have a JPanel, I want this JPanel

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 09:03

    In order to make panels in a frame individually resizable you need to add them onto a JSplitPane.

    Instead of putting it in the South portion of the Frame, put the JSplitPane in the Center. The split pane will make the bottom panel in the split seem like it is in the South, and the top panel in the split will be in the Center of the frame.

    Make sure you set the orientation of the two panels with setOrientation(JSplitPane.VERTICAL_SPLIT ).

    Then, you can resize the panels that are in the pane.

提交回复
热议问题