0

I am creating a GUI in which when I click on a button "OK", new components will appear (button, text field, label etc..). I did the code but when I click on the button, I get a message on the console "Button clicked" but the components are never added to my window! here is my code for the button clicked action.

public void actionPerformed(ActionEvent arg0){

    if(arg0.getSource() == button_ok){
        System.out.println("Adding dynamic components");
        JPanel cell7 = new JPanel();
        Box box = Box.createHorizontalBox();
        JButton button_next = new JButton("Button_next");
        JLabel label = new JLabel("Hello");
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.gridheight = 1;
        container.add(cell7,gbc);
        box.add(label);
        box.add(button_next);
        cell7.add(box);
        container.repaint();
        fenetre.repaint();
    }
}

If you need the entire code (that creates a window and show non dynamic components tell me!) Any help with this please? :)

iMadz
  • 41
  • 1
  • 7

0 Answers0