1 14 package org.wings; 15 16 import org.wings.plaf.ToggleButtonCG; 17 18 import javax.swing.*; 19 20 24 public class SToggleButton extends SAbstractButton { 25 26 public SToggleButton(String text) { 27 super(text); 28 } 29 30 public SToggleButton(SIcon icon) { 31 super(); 32 setIcon(icon); 33 } 34 35 41 public SToggleButton(Action action) { 42 super(action); 43 } 44 45 public SToggleButton() { 46 } 47 48 public void setCG(ToggleButtonCG cg) { 49 super.setCG(cg); 50 } 51 52 public void processLowLevelEvent(String action, String [] values) { 53 processKeyEvents(values); 54 55 boolean origSelected = isSelected(); 56 57 if (getGroup() != null) { 58 getGroup().setDelayEvents(true); 59 setSelected(parseSelectionToggle(values[0])); 60 getGroup().setDelayEvents(false); 61 } else { 62 setSelected(parseSelectionToggle(values[0])); 63 } 65 66 if (isSelected() != origSelected) { 67 SForm.addArmedComponent(this); 69 } } 71 72 77 protected boolean parseSelectionToggle(String toggleParameter) { 78 if (getShowAsFormComponent()) { 80 return !isSelected(); 81 } 83 if ("1".equals(toggleParameter)) 84 return true; 85 else if ("0".equals(toggleParameter)) 86 return false; 87 88 89 return isSelected(); 91 } 92 93 } 94 95 96 | Popular Tags |