1 33 34 package edu.rice.cs.drjava.ui.config; 35 36 import javax.swing.*; 37 import edu.rice.cs.drjava.config.*; 38 import edu.rice.cs.drjava.*; 39 import java.awt.*; 40 import java.awt.event.*; 41 42 43 47 public class BooleanOptionComponent extends OptionComponent<Boolean > { 48 protected JCheckBox _jcb; 49 50 56 public BooleanOptionComponent(BooleanOption opt, String text, Frame parent) { 57 super(opt, "", parent); 58 _jcb = new JCheckBox(); 59 _jcb.setText(text); 60 _jcb.addActionListener(new ActionListener() { 61 public void actionPerformed(ActionEvent e) { notifyChangeListeners(); } 62 }); 63 64 _jcb.setSelected(DrJava.getConfig().getSetting(_option).booleanValue()); 65 } 66 67 73 public BooleanOptionComponent(BooleanOption opt, String text, 74 Frame parent, String description) { 75 this(opt, text, parent); 76 setDescription(description); 77 } 78 79 82 public void setDescription(String description) { 83 _jcb.setToolTipText(description); 84 _label.setToolTipText(description); 85 } 86 87 90 public boolean updateConfig() { 91 Boolean oldValue = DrJava.getConfig().getSetting(_option); 92 Boolean newValue = Boolean.valueOf(_jcb.isSelected()); 93 94 if (!oldValue.equals(newValue)) DrJava.getConfig().setSetting(_option, newValue); 95 96 return true; 97 } 98 99 100 public void setValue(Boolean value) { 101 _jcb.setSelected(value.booleanValue()); 102 } 103 104 107 public JComponent getComponent() { return _jcb; } 108 } 109 | Popular Tags |