Beispiel #1
0
 @Override
 public void paintIcon(Component c, Graphics g, int x, int y) {
   AbstractButton abstractButton = (AbstractButton) c;
   ButtonModel buttonModel = abstractButton.getModel();
   int w = getIconWidth();
   int h = getIconHeight();
   if (g instanceof Graphics2D) {
     Graphics2D g2 = (Graphics2D) g;
     RenderingHints rh =
         new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     g2.setRenderingHints(rh);
     float s = SizeHelper.getMinimalStrockWidth();
     g2.setStroke(new BasicStroke(s));
   }
   g.setColor(Color.WHITE);
   g.fillOval(x, y, w - 1, h - 1);
   if (buttonModel.isEnabled()) {
     g.setColor(Color.BLACK);
   } else {
     g.setColor(Color.GRAY);
   }
   g.drawOval(x, y, w - 1, h - 1);
   if (buttonModel.isSelected()) {
     int dx = (int) Math.round(0.25 * w);
     int dy = (int) Math.round(0.25 * h);
     g.fillOval(x + dx, y + dy, w - 2 * dx, h - 2 * dy);
   }
 }