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