1
6 import javax.swing.*;
7 import java.awt.geom.*;
8 import java.awt.*;
9
10 public class LineIcon implements Icon {
11
12 int width;
13 int height;
14 Stroke stroke;
15
16 public LineIcon(int w,int h,Stroke st) {
17 width = w;
18 height = h;
19 stroke = st;
20 }
21
22 public int getIconHeight() {
23 return(height);
24 }
25
26 public int getIconWidth() {
27 return(width);
28 }
29
30 public void paintIcon(Component c,Graphics g,int x,int y) {
31 Graphics2D gr = (Graphics2D)g;
32 gr.clearRect(x,y,width,height);
33 GeneralPath line = new GeneralPath();
34 line.moveTo(x+width/4,y+height);
35 line.quadTo(x+width*3/4,y+height/2,x+width/2,y);
36 Stroke s = gr.getStroke();
37 gr.setStroke(stroke);
38 gr.setColor(Color.black);
39 gr.setColor(Color.black);
40 gr.draw(line);
41 gr.setStroke(s);
42 }
43 }
44