Panel won't update
publicclass TermPanelextends JPanel
{
private CourseStorer courseStorer =null;
private Course currentCourse =null;
private JComboBox allCourses =null;
private ArrayList<Author> authorsOfCourse =null;
private JPanel AUTHOR_PANEL =null;
/**
* Construct a TermPanel object.
* @param courseStorer An object containing
* information about all course and authors
* in the database, along with their respective
* questions.
*/
public TermPanel(CourseStorer courseStorer)
{
this.courseStorer = courseStorer;
this.currentCourse = courseStorer.getCourses().get(0);
setBackground(Color.white);
setPreferredSize(new Dimension(600, 600));
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
// Initialize the Authors ArrayList
authorsOfCourse = currentCourse.getAuthors();
// Add all the courses to the JComboBox as well as the actionListener.
allCourses =new JComboBox();
allCourses.addItemListener(new CourseComboBoxListener());
for (int i = 0; i < courseStorer.getCourses().size(); i++)
allCourses.addItem(courseStorer.getCourses().get(i));
JPanel coursePanel =new JPanel();
coursePanel.setBackground(Color.white);
coursePanel.add(new JLabel("Course Name: "));
coursePanel.add(allCourses);
AUTHOR_PANEL =new JPanel();
AUTHOR_PANEL.setBackground(Color.white);
AUTHOR_PANEL.setLayout(new GridLayout(0,1));
add(coursePanel);
add(AUTHOR_PANEL);
}
privatevoid updateGUI()
{
AUTHOR_PANEL.removeAll();
for (int i = 0; i < authorsOfCourse.size(); i++)
{
Author author = authorsOfCourse.get(i);
JPanel temp =new JPanel();
temp.setBackground(Color.white);
temp.add(new JLabel(author.getName()));
temp.add(new JLabel("Easy " + author.getNumOfEasyQ()));
temp.add(new JLabel("Medium " + author.getNumOfMedQ()));
temp.add(new JLabel("Hard " + author.getNumOfDiffQ()));
temp.add(numOfQuestions[i]);
AUTHOR_PANEL.add(temp);
}
}
privateclass CourseComboBoxListenerimplements ItemListener
{
publicvoid itemStateChanged(ItemEvent ie)
{
Course myCourse = (Course) allCourses.getSelectedItem();
authorsOfCourse = myCourse.getAuthors();
updateGUI();
}
}
}
The problem is that when ever I click on the drop down menu, the AUTHOR_PANEL
remains the same, it never changes like it is suppose to.
After debugging I figured out that updateGUI() is being entered, but the changes aren't begin reflected on the actual GUI for some reason.
Any help would be greatly appreciated.
Thank you.

