View Javadoc

1   package org.catacomb.graph.gui;
2   
3   import org.catacomb.icon.IconLoader;
4   import org.catacomb.interlish.structure.IntActor;
5   
6   
7   import java.awt.Color;
8   import java.awt.event.ActionEvent;
9   import java.awt.event.ActionListener;
10  
11  import javax.swing.Icon;
12  import javax.swing.JRadioButton;
13  
14  
15  
16  public class IconButton extends JRadioButton implements ActionListener {
17      static final long serialVersionUID = 1001;
18      IntActor intActor;
19      int action;
20  
21      Color cbg;
22      Color csel;
23  
24      public IconButton(String iconName, int iact, IntActor actor) {
25          super();
26  
27          cbg = new Color(200, 200, 200);
28          setBackground(cbg);
29  
30          intActor = actor;
31          action = iact;
32  
33          Icon icon = IconLoader.createImageIcon(iconName);
34          setIcon(icon);
35  
36  
37          setToolTipText(iconName);
38  
39          addActionListener(this);
40  
41          attachRollover();
42      }
43  
44  
45      public void setBg(Color c) {
46          cbg = c;
47          setBackground(c);
48      }
49  
50      public void attachRollover() {
51  
52  
53          RolloverEffect rollover = new RolloverEffect(this,
54                  RolloverEffect.ETCHED_DOWN,
55                  RolloverEffect.ETCHED_UP);
56          addMouseListener(rollover);
57      }
58  
59  
60  
61  
62      public void actionPerformed(ActionEvent aev) {
63          intActor.intAction(action);
64      }
65  
66  
67  
68  
69  
70  }