You're making changes to the wrong CalendarPanel object, to one created specifically in the listener. Meanwhile the CalendarPanel object that is displayed knows nothing of these changes.
class RadioButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
// the line below creates a *new* CalendarPanel object
// one completely unrelated to the displayed CalendarPanel
CalendarPanel cal = new CalendarPanel();
cal.formatCalendar(getDaysInMonth(), getFirstDayOfWeek());
cal.revalidate();
cal.repaint();
}
}
___________________________
The solution is to pass a reference to the displayed CalendarPanel object to your listener, and make changes on that.
class RadioButtonListener implements ActionListener
{
private CalendarPanel cal;
public RadioButtonListener(CalendarPanel cal) {
this.cal = cal;
}
public void actionPerformed(ActionEvent e)
{
cal.formatCalendar(getDaysInMonth(), getFirstDayOfWeek());
cal.revalidate();
cal.repaint();
}
}
When creating this above listener, you'll need to pass a reference to the valid displayed CalendarPanel object to allow it to work.
Edit
You state in comment:
Okay, I did that and instantiated it in my Frame constructor (which also creates and adds my other panels) but it creates a null pointer exception.
If you have any significant changes to your question, please edit your question (as I'm doing now), by posting new code and new description to the bottom of your current question. Don't change the original question or code if you can avoid doing so as not to invalidate your answers.
Now on to your problem: I can only guess since we are not seeing your changed code, but are you passing in the CalendarPlayer variable into the RadioButtonListener constructor before you've assigned a valid CalendarPlayer to its variable. If so, that would explain this since you would be passing null
into the RadioButtonListener constructor. The solution would be to assign a CalendarPlayer to its variable first before calling the RadioButtonListener constructor.
Edit 2
You're likely creating two RadioButtonListener's, one using the default constructor, the one without the parameter, and one that uses the parameter. Get rid of that default constructor, again the one without the parameter, don't create two of these objects (it makes no sense and makes me scratch my head why you'd do this) and work on figuring out a way to get the proper reference into the listener. You should be able to figure this out if you think on it, and don't just copy and paste code from here.