0

I would like to change my current layout to a new one, more advanced, but I have some issues with it. The current layout is as this: enter image description here

All the displayed elements are in a panel (bottom panel, there is a top one which just includes JTable but is not relevant in this case) the checkboxes are in a JScrollPaneBox, which border layout is BorderLayout.CENTER, then the buttons are in a Box and added to the panel with border layout BorderLayout.EAST, and the search field is added to the panel with borderlayout BorderLayout.SOUTH But this layout is especially 'ugly' when the app is on fullscreen. enter image description here

I would like to have a layout like this: https://wireframe.cc/Kb05km

How can I add the two labels and add a space between checkboxes and search field? Also how can I limit the maximum width of checkboxes' ScrollPaneBox and the search field? Thanks!

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Sam333
  • 199
  • 14
  • 1
    *I would like to have a layout like this* - and what is the problem? Looks like a scroll pane is added to the CENTER. Then another panel is added to the PAGE_END. This second panel can also contain nested panels with different layout managers to achieve your layout. *Also how can I limit the maximum width of checkboxes' ScrollPaneBox and the search field?* - it is controlled by the layout manager. Read the Swing tutorial on [Layout Managers](https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html) for the basics of each layout manager and working examples. – camickr Mar 10 '21 at 19:19
  • the problem is asked in the last sentence, i.e. how can I add a space between elements (search field and scroll pane), and how can I limit it's width? – Sam333 Mar 10 '21 at 19:21
  • 1
    *"I would like to have a layout like this:"* Is the GUI resizable? If so, how should the extra width and height be assigned? Note that most good layouts result from combining layout managers - each specific to a section of the overall GUI. – Andrew Thompson Mar 10 '21 at 19:21
  • 1
    Space around elements depends on which Swing layout we're talking about. The FlowLayout, BoxLatout, BorderLayout, GridLaypout, and GridBagLayouit all have parameters or methods for putting space around Swing elements. – Gilbert Le Blanc Mar 10 '21 at 19:25
  • 1
    *"How can I add the two labels and add a space between checkboxes and search field?"* Layout padding or an `EmptyBorder` is what I'd usually use for that. *"how can I limit it's width?"* I'd usually put the component in a `FlowLayout`. That will try to assign a component its preferred size, and won't stretch it to fill the container. – Andrew Thompson Mar 10 '21 at 19:25
  • For more info on what @GilbertLeBlanc & I suggested re white space, see [this Q&A](https://stackoverflow.com/questions/17874717/providing-white-space-in-a-swing-gui). – Andrew Thompson Mar 10 '21 at 19:27

0 Answers0