upicon.java
来自「MyUploader 是一款使用 http 协议(RFC 1867)用于上传文件」· Java 代码 · 共 84 行
JAVA
84 行
package javaatwork.myuploader.icons;import java.awt.Color;import java.awt.Component;import java.awt.Graphics;import javax.swing.Icon;import javax.swing.SwingConstants;/** * Class for creating a up-arrow-icon. * * @author Johannes Postma */public class UpIcon implements Icon, SwingConstants { private int width = 11; private int height = 6; private int[] xPoints = new int[3]; private int[] yPoints = new int[3]; /** * Constructs a new UpIcon. */ public UpIcon() { xPoints[0] = 0; yPoints[0] = height; xPoints[2] = width; yPoints[2] = height; xPoints[1] = width/2; yPoints[1] = 0; } /** * Gets the height of the icon. * * @return the height in pixels of this icon */ public int getIconHeight() { return height; } /** * Gets the width of the icon. * * @return The width in pixels of this icon */ public int getIconWidth() { return width; } /** * Paints the icon. * The top-left corner of the icon is drawn at * the point (<code>x</code>, <code>y</code>) * in the coordinate space of the graphics context <code>g</code>. * If this icon has no image observer, * this method uses the <code>c</code> component * as the observer. * * @param c the component to be used as the observer * if this icon has no image observer * @param g the graphics context * @param x the X coordinate of the icon's top-left corner * @param y the Y coordinate of the icon's top-left corner */ public void paintIcon(Component c, Graphics g, int x, int y) { int length = xPoints.length; int adjustedXPoints[] = new int[length]; int adjustedYPoints[] = new int[length]; for (int i = 0; i < length; i++) { adjustedXPoints[i] = xPoints[i] + x; adjustedYPoints[i] = yPoints[i] + y; } g.setColor(Color.gray); g.fillPolygon(adjustedXPoints, adjustedYPoints, length); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?