I am working in java with SWING and AWT components. I am confused about layouts in it. I have add a panel and add buttons inside that panel using setBounds(), then add this panel to a frame which is using flow layout. But the panel is not been able to display itself.. Here is my code:
public class MainWindow implements ActionListener {
private JFrame frame;
private JPanel panel;
private JButton play;
private JButton exit;
public MainWindow() {
frame = new JFrame();
panel = new JPanel();
play = new JButton(new ImageIcon("button.png"));
exit = new JButton(new ImageIcon("exit.png"));
panel.setLayout(null);
play.setBounds(200, 200, 90, 40);
exit.setBounds(200, 300, 90, 40);
panel.setBackground(new Color(45, 204, 112));
play.addActionListener(this);
exit.addActionListener(this);
panel.add(play);
panel.add(exit);
Container cont = frame.getContentPane();
cont.setLayout(new FlowLayout());
cont.add(panel);
frame.setSize(800, 700);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}