1 7 8 package org.jdesktop.swing.icon; 9 10 import java.awt.BorderLayout ; 11 import java.awt.Color ; 12 import java.awt.Component ; 13 import java.awt.Graphics ; 14 15 import javax.swing.Icon ; 16 import javax.swing.JFrame ; 17 import javax.swing.JLabel ; 18 19 25 public class ColumnControlIcon implements Icon { 26 private int width = 10; 27 private int height = 10; 28 29 30 public ColumnControlIcon() { 31 } 32 33 public int getIconWidth() { 34 return width; 35 } 36 37 public int getIconHeight() { 38 return height; 39 } 40 41 public void paintIcon(Component c, Graphics g, int x, int y) { 42 Color color = c.getForeground(); 43 g.setColor(color); 44 45 g.drawLine(x, y, x+8, y); 47 g.drawLine(x, y+2, x+8, y+2); 48 g.drawLine(x, y+8, x+2, y+8); 49 50 g.drawLine(x, y+1, x, y+7); 52 g.drawLine(x+4, y+1, x+4, y+4); 53 g.drawLine(x+8, y+1, x+8, y+4); 54 55 g.drawLine(x+3, y+6, x+9, y+6); 57 g.drawLine(x+4, y+7, x+8, y+7); 58 g.drawLine(x+5, y+8, x+7, y+8); 59 g.drawLine(x+6, y+9, x+6, y+9); 60 61 } 62 63 public static void main(String args[]) { 64 JFrame frame = new JFrame (); 65 JLabel label = new JLabel (new ColumnControlIcon()); 66 frame.getContentPane().add(BorderLayout.CENTER, label); 67 frame.pack(); 68 frame.setVisible(true); } 70 71 } 72 | Popular Tags |