I've been trying to dynamically add/remove radio buttons to/from a JPanel and RadioGroup but it doesn't seem to work after initialisation. The JPanel layout is set to Flow Layout. I have the following method:
private void addButton(){
JRadioButton jRadioButton = new JRadioButton("1");
jPanel1.add(jRadioButton);
}
If I call this after initComponents in my JFrame Form constructor, it successfully adds a button to the JPanel. If I use a JButton on the form which calls the same method on click, nothing seems to happen. Why isn't it adding more buttons with each click? I've also been trying to remove radio buttons after initialisation and that doesn't seem to work either. I must be missing something very simple?