I have an issue with my code below, the buttons and the Panel aren't displayed until mouseover Could you please help me to identify the reason of this issue ?
Thank you in advance for your help.
Kind regards
JButton atelier;JButton examen;
private JPanel contentPane;
public void principe() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(50, 50,1000,700);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
JPanel Evenement = new JPanel();
Evenement.setBounds(3, 200, 251, 62);
contentPane.add(Evenement);
Evenement.setLayout(null);
Evenement.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
choix();}
});
JLabel lblNewLabel_5 = new JLabel("Activité");
lblNewLabel_5.setBounds(128, 13, 111, 36);
Evenement.add(lblNewLabel_5);
}
public void choix() {
JPanel m= new JPanel();
m.setBackground(new Color(70, 130, 180));
m.setBounds(260,20, 689, 75);
m.setLayout(null);
atelier = new JButton("Atelier");
atelier.setBounds(486,15, 137, 40);
atelier.setBackground(new Color(200, 180, 150));
m.add(atelier);
examen = new JButton("Examen");
examen.setBounds(344,15, 137, 40);
examen.setBackground(new Color(200, 180, 150));
m.add(examen);
contentPane.add(m);
}