01: package com.memoire.vainstall.xui;
02:
03: import com.memoire.vainstall.xui.*;
04: import javax.swing.*;
05: import javax.swing.border.*;
06: import java.awt.*;
07: import java.awt.event.*;
08:
09: public class XuiButtonBorder extends AbstractBorder {
10: public void paintBorder(Component c, Graphics g, int x, int y,
11: int w, int h) {
12: AbstractButton button = (AbstractButton) c;
13: ButtonModel model = button.getModel();
14:
15: Color color = Color.magenta;
16:
17: if (model.isEnabled()) {
18: if (model.isPressed() && model.isArmed())
19: color = Color.red;
20: else if (model.isSelected())
21: color = Color.green;
22: else
23: color = c.getForeground();
24: } else
25: color = Color.gray;
26:
27: int r = h / 2;
28:
29: g.setColor(color);
30: g.drawArc(x, y, 2 * r, h - 2, 90, 180);
31: g.drawArc(x + w - 1 - 2 * r, y, 2 * r, h - 2, 270, 180);
32: g.drawArc(x + 1, y, 2 * r, h - 1, 90, 180);
33: g.drawArc(x + w - 1 - 2 * r - 1, y, 2 * r, h - 2, 270, 180);
34: g.drawArc(x, y + 1, 2 * r, h - 2, 90, 180);
35: g.drawArc(x + w - 1 - 2 * r - 1, y + 1, 2 * r, h - 2, 270, 180);
36:
37: g.drawLine(x + r, y, x + w - 1 - r, y);
38: g.drawLine(x + r, y + h - 1, x + w - 1 - r, y + h - 1);
39: g.drawLine(x + r, y + 1, x + w - 1 - r, y + 1);
40: g.drawLine(x + r, y + h - 2, x + w - 1 - r, y + h - 2);
41: }
42:
43: public Insets getBorderInsets(Component c) {
44: return new Insets(5, 5, 5, 5);
45: }
46:
47: public boolean isBorderOpaque() {
48: return false;
49: }
50: }
|