01: package com.memoire.vainstall.xui;
02:
03: import java.awt.*;
04: import javax.swing.*;
05: import javax.swing.border.*;
06:
07: public class XuiPanel extends JPanel {
08: public XuiPanel() {
09: super ();
10: setBackground(new Color(128, 192, 192));
11: setForeground(new Color(64, 96, 96));
12: setBorder(null);
13: setOpaque(true);
14: }
15:
16: public void paint(Graphics _g) {
17: ((Graphics2D) _g).setRenderingHint(
18: RenderingHints.KEY_ANTIALIASING,
19: RenderingHints.VALUE_ANTIALIAS_ON);
20: super .paint(_g);
21: }
22:
23: public void paintComponent(Graphics _g) {
24: if (!isOpaque())
25: return;
26:
27: Color bg = getBackground();
28: Color fg = getForeground();
29:
30: int rb = bg.getRed();
31: int gb = bg.getGreen();
32: int bb = bg.getBlue();
33: int rf = fg.getRed();
34: int gf = fg.getGreen();
35: int bf = fg.getBlue();
36:
37: int w = getWidth();
38: int h = getHeight();
39:
40: int jmin = 0;
41: int jmax = h;
42:
43: Rectangle clip = _g.getClipBounds();
44: if (clip != null) {
45: jmin = clip.y;
46: jmax = clip.y + clip.height;
47: }
48:
49: for (int j = jmin; j < jmax; j++) {
50: _g.setColor(new Color(Math.min(255, rb + (rf - rb) * j
51: / (h - 1) + j % 2), Math.min(255, gb + (gf - gb)
52: * j / (h - 1) + j % 3), Math.min(255, bb
53: + (bf - bb) * j / (h - 1) + j % 4)));
54: _g.drawLine(0, j, w - 1, j);
55: }
56: }
57: }
|