1 package org.wcb.gui.component;
2
3 import javax.swing.*;
4 import java.awt.*;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 public class JScanLinePanel extends JPanel {
34
35 private Color grad_even = new Color(0xf6f5f4);
36 private Color grad_odd = new Color(0xa7a5a3);
37
38
39 public Color getGradEven() {
40 return grad_even;
41 }
42
43 public void setGradEven(Color grad_even) {
44 this.grad_even = grad_even;
45 }
46
47 public Color getGradOdd() {
48 return grad_odd;
49 }
50
51 public void setGradOdd(Color grad_odd) {
52 this.grad_odd = grad_odd;
53 }
54
55 protected void paintComponent(Graphics g) {
56 super.paintComponent(g);
57 Graphics2D g2 = (Graphics2D) g;
58 g2.setBackground(grad_odd);
59 for (int y = 0; y < getHeight(); y++) {
60 g2.setColor(grad_even);
61 g2.drawLine(0, y, getWidth(), y);
62 g2.drawLine(0, y + 1, getWidth(), y + 1);
63 y = y + 2;
64 }
65 }
66
67 public static void main(String[] args) {
68 JFrame frame = new JFrame();
69 JScanLinePanel pane = new JScanLinePanel();
70 pane.setPreferredSize(new Dimension(200, 300));
71 frame.add(pane);
72 frame.setVisible(true);
73 frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
74 }
75 }