Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit:</strong> Gah! Someone beat me to it...Here's a slightly different approach regardless!</p> <p>There's many ways to do this, but I would try the following:</p> <ul> <li><code>JFrame</code> > <code>BoxLayout</code> using <code>X_AXIS</code> <ul> <li><code>JPanel</code> #1 > <code>BorderLayout</code> <ul> <li>[<code>BorderLayout.NORTH</code>] <code>JPanel</code> for buttons > <code>FlowLayout</code> using <code>FlowLayout.LEFT</code></li> <li>[<code>BorderLayout.CENTER</code>] <code>JScrollPane</code> with Table #1</li> </ul></li> <li><code>JPanel</code> #2 > <code>BorderLayout</code> <ul> <li>[<code>BorderLayout.NORTH</code>] <code>JPanel</code> for buttons > <code>FlowLayout</code> using <code>FlowLayout.LEFT</code></li> <li>[<code>BorderLayout.CENTER</code>] <code>JScrollPane</code> with Table #2</li> </ul></li> </ul></li> </ul> <p>Using <code>BoxLayout</code> and <code>BorderLayout.CENTER</code> will ensure that the tables resize with the frame and fill up as much space as they can. Here's a simple example:</p> <pre><code>public class TwoTableJFrameTest extends JFrame { public TwoTableJFrameTest() { setTitle("Two Table Layout"); setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS)); JPanel table1Panel = new JPanel(new BorderLayout(5, 5)); JPanel table1ButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); table1ButtonPanel.add(new JButton("Button 1")); table1ButtonPanel.add(new JButton("Button 2")); table1ButtonPanel.add(new JButton("Button 3")); JTable table1 = new JTable(new DefaultTableModel(new Object[]{"Column 1", "Column 2"}, 10)); table1Panel.add(table1ButtonPanel, BorderLayout.NORTH); table1Panel.add(new JScrollPane(table1)); JPanel table2Panel = new JPanel(new BorderLayout(5, 5)); JPanel table2ButtonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); table2ButtonPanel.add(new JButton("Button 1")); table2ButtonPanel.add(new JButton("Button 2")); table2ButtonPanel.add(new JButton("Button 3")); JTable table2 = new JTable(new DefaultTableModel(new Object[]{"Column 1", "Column 2"}, 10)); table2Panel.add(table2ButtonPanel, BorderLayout.NORTH); table2Panel.add(new JScrollPane(table2)); add(table1Panel); add(table2Panel); pack(); } } </code></pre> <p><img src="https://i.stack.imgur.com/fF6aH.png" alt="two table layout"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload