1

I am using group radio buttons.What i want is that when i have selected the particular radio button then i press the button(call it show button) to display the results(on a chart placed in a panel) according to the selected radio button.The problem is when i press the show button it does not display results until i click the panel though i have not written any code when i press the panel.Here is my code

private void Show1MouseClicked(java.awt.event.MouseEvent evt) {
    if (jRadioButton1.isSelected()) {
        Panel.removeAll();
       //some code
    }

    Panel.setVisible(true);
    Panel.add(frame1);
    Panel.setSize(700, 260);
}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Xara
  • 8,748
  • 16
  • 52
  • 82

2 Answers2

3

Use a CardLayout, as shown here.

Game view High Scores view

As to the chart itself, change the model if the data changes.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
2

You probably need to call repaint() on your panel after the change. When you interact with the panel with your mouse it is calling repaint() behind the scenes.

n00begon
  • 3,503
  • 3
  • 29
  • 42