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.

asked Apr 23, 2015 at 15:28
2
  • 1
    For better help sooner, post an MCVE (Minimal Complete Verifiable Example) or SSCCE (Short, Self Contained, Correct Example). Commented Apr 24, 2015 at 0:04
  • See white space for an example (in the form of an MCVE).. Commented Apr 24, 2015 at 0:07

1 Answer 1

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.

answered Apr 23, 2015 at 15:32
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.