Skip to content

anonymous /gist:4575586

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.