Java GUI Layouts

前端 未结 5 1955
耶瑟儿~
耶瑟儿~ 2021-01-07 02:55

Could somebody tell me which java layout I need to use to achieve the layout below:

\"Correct

5条回答
  •  再見小時候
    2021-01-07 03:13

    I would just use MigLayout for the high level page layout, and then dropdown to the simple layout managers for the . It's essentially a grid layout, but it's very easy to use. Miglayout cannot wrap items though, and this is apparently a design issue in Swing. WrapLayout is a layout manager that gives you that functionality, but it can have issues.

    http://tips4java.wordpress.com/2008/11/06/wrap-layout/

    Looking at the screen shot you've provided I've mocked up the way you would want to divide it up. You'd have 9 rows total (0-8) and 3 columns total (0-2). For stuff like the controls at the very top, you will "span" them across all three columns.

    For the text, you just put the text inside of it's individual box in row 1, column 1 for First Name, or row 2, column 1 for Last Name, etc.

    You do the same thing with the input boxes.

    In the picture below the blue are the columns and the orange are the rows.

    grid layout

    So to summarize;

    • Use Miglayout for your high level layout. It's like using a table in HTML.
    • Use other layout managers to layout the items inside of the grid boxes that Miglayout provides.

提交回复
热议问题