package exercise2.plaf.concrete; import java.awt.*; import java.beans.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.*; import exercise2.choice.*; import exercise2.plaf.*; import widget.*; public class CChoiceBodyUI extends ChoiceBodyUI implements PropertyChangeListener { protected ChoiceBody body; protected ChoicePane choicePane; public static ComponentUI createUI(JComponent c) { return new CChoiceBodyUI(); } public void installUI(JComponent c) { // Install defaults. this.body = (ChoiceBody)c; body.setOpaque(true); body.setBackground(BACKGROUND_COLOR); body.setLayout(new GridBagLayout()); // Install the choice pane. choicePane = new ChoicePane(body.getType(), body.getChoices()); choicePane.setOpaque(false); choicePane.addPropertyChangeListener(this); GridBagHelper.addComponent( body, choicePane, 0, 0, 1, 1, new Insets(2, 2, 2, 2), 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); } public void uninstallUI(JComponent c) { } public void propertyChange(PropertyChangeEvent e) { String name = e.getPropertyName(); if (name == ChoicePane.SELECTED_PROP) { body.setSelected(choicePane.getSelected()); } } }