Skip to content

Instantly share code, notes, and snippets.

Created January 19, 2013 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4575586 to your computer and use it in GitHub Desktop.
Save anonymous/4575586 to your computer and use it in GitHub Desktop.
public class ColorPanel extends Panel implements Resettable {
Model model;
Choice lineColorChoice;
Choice fillColorChoice;
public ColorPanel(Model mdl) {
model = mdl;
lineColorChoice = new Choice();
fillColorChoice = new Choice();
for(String msg : Model.lineColorChoice) {
lineColorChoice.add(msg);
}
lineColorChoice.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
model.setCurrentShapeType(lineColorChoice.getSelectedItem());
}
});
this.add(lineColorChoice);
for(String msg : Model.fillColorChoice) {
fillColorChoice.add(msg);
}
fillColorChoice.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
model.setCurrentShapeType(fillColorChoice.getSelectedItem());
}
});
this.add(fillColorChoice);
}
}
public void resetComponents() {
lineColorChoice.select(0);
fillColorChoice.select(0);
model.setMessage(fillColorChoice.getSelectedItem());
model.setMessage(lineColorChoice.getSelectedItem());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment