How to layout multiple panels on a jFrame? (java)

前端 未结 2 1387
礼貌的吻别
礼貌的吻别 2020-12-30 03:26

\"Layout

I am in the process of making my own java socket game. My game is painting alright to the ful

2条回答
  •  不知归路
    2020-12-30 03:36

    You'll want to use a number of layout managers to help you achieve the basic results you want.

    Check out A Visual Guide to Layout Managers for a comparision.

    You could use a GridBagLayout but that's one of the most complex (and powerful) layout managers available in the JDK.

    You could use a series of compound layout managers instead.

    I'd place the graphics component and text area on a single JPanel, using a BorderLayout, with the graphics component in the CENTER and the text area in the SOUTH position.

    I'd place the text field and button on a separate JPanel using a GridBagLayout (because it's the simplest I can think of to achieve the over result you want)

    I'd place these two panels onto a third, master, panel, using a BorderLayout, with the first panel in the CENTER and the second at the SOUTH position.

    But that's me

提交回复
热议问题