I have the following structure in a frame:
Frame->contentPane panel->topPanel panel->table
This is the code:
private JPanel contentPane;
private JTable table;
private JPanel topPanel;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ShowList frame = new ShowList();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public ShowList() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 675, 433);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
topPanel = new JPanel();
topPanel.setBounds(76, 76, 491, 245);
contentPane.add(topPanel);
topPanel.setLayout(null);
table = new JTable();
table.setBounds(0, 0, 491, 245);
topPanel.add(table);
}
What I want to achieve is that when I resize the frame making the window bigger, the topPanel and the table that it is contained by this one resize also and do not stay the same size as they were before resizing the frame. I have read about Layouts but I can not make it work. Any suggestion?