0

So I'm working on a GUI for a project, and I would like to set it up as follows:

  • Two JTables(one on BorderLayout.WEST, the other on BorderLayout.EAST)
  • Two JComboBox's that sit above the JTables
  • One Panel that sits between the JTables(BorderLayout.CENTER)

Can someone help me with this? I'm having trouble with the spacing between the components.

Kyle Weise
  • 43
  • 1
  • 8
  • 1
    For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal Complete Verifiable Example) or [SSCCE](http://www.sscce.org/) (Short, Self Contained, Correct Example). – Andrew Thompson Apr 24 '15 at 00:04
  • See [white space](http://stackoverflow.com/a/17874718/418556) for an example (in the form of an MCVE).. – Andrew Thompson Apr 24 '15 at 00:07

1 Answers1

1

Read the BorderLayout API. You can specify the vertical and horizontal gap between the various areas of the BorderLayout. So reset the layout manager of the frame with a BorderLayout that uses your desired gaps:

BorderLayout layout = new BorderLayout(...);
frame.setLayout( layout );
frame.add(new JScrollPane(table1), BorderLayout.LINE_START);
frame.add(new JScrollPane(table2), BorderLayout.LINE_END);

Also, you can create sub panels and use different layout managers on each panel to get your desired effect.

If you need more help then post a SSCCE that demonstrates the problem.

camickr
  • 321,443
  • 19
  • 166
  • 288