Created
January 19, 2013 22:20
-
-
Save anonymous/4575586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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