ColumnControlIcon.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:2k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: ColumnControlIcon.java,v 1.3 2005/10/13 08:59:58 kleopatra Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.swingx.icon;
  22. import java.awt.BorderLayout;
  23. import java.awt.Color;
  24. import java.awt.Component;
  25. import java.awt.Graphics;
  26. import javax.swing.Icon;
  27. import javax.swing.JFrame;
  28. import javax.swing.JLabel;
  29. /**
  30.  * Icon class for rendering icon which indicates user control of
  31.  * column visibility.
  32.  * @author Amy Fowler
  33.  * @version 1.0
  34.  */
  35. public class ColumnControlIcon implements Icon {
  36.     private int width = 10;
  37.     private int height = 10;
  38.     /**@todo: need to support small, medium, large */
  39.     public ColumnControlIcon() {
  40.     }
  41.     public int getIconWidth() {
  42.         return width;
  43.     }
  44.     public int getIconHeight() {
  45.         return height;
  46.     }
  47.     public void paintIcon(Component c, Graphics g, int x, int y) {
  48.         Color color = c.getForeground();
  49.         g.setColor(color);
  50.         // draw horizontal lines
  51.         g.drawLine(x, y, x+8, y);
  52.         g.drawLine(x, y+2, x+8, y+2);
  53.         g.drawLine(x, y+8, x+2, y+8);
  54.         // draw vertical lines
  55.         g.drawLine(x, y+1, x, y+7);
  56.         g.drawLine(x+4, y+1, x+4, y+4);
  57.         g.drawLine(x+8, y+1, x+8, y+4);
  58.         // draw arrow
  59.         g.drawLine(x+3, y+6, x+9, y+6);
  60.         g.drawLine(x+4, y+7, x+8, y+7);
  61.         g.drawLine(x+5, y+8, x+7, y+8);
  62.         g.drawLine(x+6, y+9, x+6, y+9);
  63.     }
  64.     public static void main(String args[]) {
  65.         JFrame frame = new JFrame();
  66.         JLabel label = new JLabel(new ColumnControlIcon());
  67.         frame.getContentPane().add(BorderLayout.CENTER, label);
  68.         frame.pack();
  69.         frame.setVisible(true);  
  70.     }
  71. }