You can try something like this:
import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; public class Example { public static void main(String[] args) { JFrame jFrame = new JFrame(); jFrame.setTitle("Testing Title"); jFrame.setLocationRelativeTo(null); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); JPanel listPanel = new JPanel(new GridLayout(0, 2, 10, 0)); JPanel leftListPanel = new JPanel(new BorderLayout(0, 10)); JLabel leftLabel = new JLabel("Left value:"); JTextArea leftTextArea = new JTextArea("Hello Hello Hello\nTesting!\ntest"); JScrollPane leftScrollPane = new JScrollPane(leftTextArea); leftListPanel.add(leftLabel, BorderLayout.NORTH); leftListPanel.add(leftScrollPane, BorderLayout.CENTER); JPanel rightListPanel = new JPanel(new BorderLayout(0, 10)); JLabel rightLabel = new JLabel("Right value:"); JTextArea rightTextArea = new JTextArea("Hello Hello Hello\nTesting!\ntest"); JScrollPane rightScrollPane = new JScrollPane(rightTextArea); rightListPanel.add(rightLabel, BorderLayout.NORTH); rightListPanel.add(rightScrollPane, BorderLayout.CENTER); listPanel.add(leftListPanel); listPanel.add(rightListPanel); mainPanel.add(listPanel, BorderLayout.CENTER); JPanel buttonsPanel = new JPanel(new BorderLayout()); buttonsPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); buttonsPanel.add(new JButton("Do something"), BorderLayout.WEST); buttonsPanel.add(new JButton("Do something different"), BorderLayout.CENTER); buttonsPanel.add(new JButton("Do something even more different"), BorderLayout.EAST); mainPanel.add(buttonsPanel, BorderLayout.SOUTH); jFrame.setContentPane(mainPanel); jFrame.pack(); jFrame.setVisible(true); } }
Explanation:
First, I created the main JPanel with BorderLayout . This JPanel will be split horizontally, the CENTRE component will be another JPanel containing text areas and labels, and the SOUTH component will be a JPanel containing buttons.
JPanel , which contains the text areas, is assigned to GridLayout , so you can easily split it vertically and also specify hgap of 10 to add some spacing.
The left and right JPanels that fit into them are the same. They have a BorderLayout with vgap to add spacing. The NORTH component is a JLabel , and the CENTRE component is a JScrollPane containing a JTextArea .
Finally, the SOUTH component of the main JPanel is another JPanel that is again given a BorderLayout . Three JButton are added with the corresponding attributes WEST , CENTRE and EAST .
The overall result is as follows:
