1 package org.catacomb.druid.swing;
2
3 import java.util.Collections;
4
5 import javax.swing.AbstractButton;
6 import javax.swing.ButtonGroup;
7 import javax.swing.ButtonModel;
8
9
10 public class DButtonGroup extends ButtonGroup {
11
12 static final long serialVersionUID = 1001;
13
14
15 public String getSelectedName() {
16 String ret = null;
17 ButtonModel bm = getSelection();
18 if (bm != null) {
19 ret = bm.getActionCommand();
20 }
21 return ret;
22 }
23
24
25 public void setSelectedName(String s) {
26 if (s == null)
27 return;
28 ButtonModel bmsel = null;
29
30 for (AbstractButton ab : Collections.list(getElements())) {
31 if (s.equals(ab.getActionCommand())) {
32 bmsel = ab.getModel();
33 break;
34 }
35 }
36
37 if (bmsel != null) {
38 setSelected(bmsel, true);
39 }
40 }
41
42
43
44 public boolean hasElementCalled(String s) {
45 boolean bok = false;
46
47 if (s != null) {
48 for (AbstractButton ab : Collections.list(getElements())) {
49 if (s.equals(ab.getActionCommand())) {
50 bok = true;
51 break;
52 }
53 }
54 }
55 return bok;
56 }
57
58 }