01: package com.memoire.vainstall.xui;
02:
03: import java.awt.*;
04: import javax.swing.*;
05: import javax.swing.border.*;
06:
07: public class XuiRadioButton extends JRadioButton implements Icon {
08: public XuiRadioButton(String _text) {
09: super (_text);
10: setForeground(Color.black);
11: setBackground(new Color(64, 96, 96));
12: setFont(new Font("SansSerif", Font.PLAIN, 12));
13: setBorder(new XuiButtonBorder());
14: setPreferredSize(new Dimension(100, 30));
15: setOpaque(false);
16: setContentAreaFilled(false);
17: setFocusPainted(false);
18:
19: setIcon(this );
20: }
21:
22: public void paint(Graphics _g) {
23: ((Graphics2D) _g).setRenderingHint(
24: RenderingHints.KEY_ANTIALIASING,
25: RenderingHints.VALUE_ANTIALIAS_ON);
26: super .paint(_g);
27: }
28:
29: public int getIconWidth() {
30: return 16;
31: }
32:
33: public int getIconHeight() {
34: return 16;
35: }
36:
37: public void paintIcon(Component _c, Graphics _g, int _x, int _y) {
38: _g.setColor(_c.getForeground());
39: _g.fillOval(_x, _y, 16, 16);
40:
41: JRadioButton b = (XuiRadioButton) _c;
42: ButtonModel m = b.getModel();
43:
44: if (m.isPressed() && m.isArmed())
45: _g.setColor(Color.red);
46: else if (b.isSelected())
47: _g.setColor(Color.white);
48: else
49: _g.setColor(_c.getBackground());
50:
51: _g.fillOval(_x + 3, _y + 3, 10, 10);
52: }
53: }
|