📄 upicon.java
字号:
/*
* Copyright 2007 JavaAtWork All rights reserved.
* Use is subject to license terms.
*/
package com.javaatwork.mydownloader.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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -