1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
/*
* ToolButtonGroup.java
*
* Created on 16 March 2003, 17:22
*/
package org.tigris.toolbutton;
import java.util.ArrayList;
import java.util.Iterator;
/**
* A group of ToolButtons to aid radio style effect
*
* @author Bob Tarling
*/
public class ToolButtonGroup {
ArrayList buttons = new ArrayList();
ToolButton defaultButton;
/** Creates a new instance of StickyButtonGroup */
public ToolButtonGroup() {
}
public ToolButton add(ToolButton toolButton) {
buttons.add(toolButton);
toolButton.setInGroup(this);
return toolButton;
}
public void buttonSelected(ToolButton toolButton) {
Iterator it = buttons.iterator();
while (it.hasNext()) {
ToolButton button = (ToolButton)it.next();
if (button != toolButton) {
button.setSelected(false);
button.setBorderPainted(false);
} else {
button.setBorderPainted(true);
}
}
}
public ToolButton setDefaultButton(ToolButton toolButton) {
defaultButton = toolButton;
return toolButton;
}
public ToolButton getDefaultButton() {
return defaultButton;
}
}
|