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.
-
1For better help sooner, post an MCVE (Minimal Complete Verifiable Example) or SSCCE (Short, Self Contained, Correct Example).Andrew Thompson– Andrew Thompson2015年04月24日 00:04:51 +00:00Commented Apr 24, 2015 at 0:04
-
See white space for an example (in the form of an MCVE)..Andrew Thompson– Andrew Thompson2015年04月24日 00:07:01 +00:00Commented Apr 24, 2015 at 0:07
1 Answer 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
camickr
325k21 gold badges174 silver badges293 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-java