Skip to content

anonymous /gist:4574790

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
package ui.panels;
import interfaces.Resettable;
import java.awt.Choice;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import model.Model;
public class MainPanel extends Panel implements Resettable {
ActionPanel actionPanel;
ChoicePanel choicePanel;
ControlsPanel controlsPanel;
public MainPanel(Model model) {
choicePanel = new ChoicePanel(model);
actionPanel = new ActionPanel(model);
controlsPanel = new ControlsPanel(model);
setLayout(new GridLayout(2,1));
add(controlsPanel);
add(choicePanel);
add(actionPanel);
}
public void resetComponents() {
choicePanel.resetComponents();
controlsPanel.resetComponents();
actionPanel.resetComponents();
}
public abstract class ColorPanel extends Panel implements Resettable {
Model model;
Choice colorNames;
public ColorPanel(Model mdl) {
model = mdl;
colorNames = new Choice();
for(String msg : Model.colorNames) {
colorNames.add(msg);
}
colorNames.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
model.setCurrentShapeType(colorNames.getSelectedItem());
}
});
this.add(colorNames);
}
public void resetComponents() {
colorNames.select(0);
model.setMessage(colorNames.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.