1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| protected void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
g2.setStroke(ROUNDED);
int[] xPoints = {0, width / 2, width / 2, width, width / 2, width / 2, 0};
int q = height / 4;
int[] yPoints = {q, q, 0, 2 * q, 4 * q, 3 * q, 3 * q};
GeneralPath arrow = new GeneralPath(GeneralPath.WIND_EVEN_ODD, xPoints.length);
arrow.moveTo(xPoints[0], yPoints[0]);
for (int index = 1; index < xPoints.length; index++)
{
arrow.lineTo(xPoints[index], yPoints[index]);
}
GradientPaint p1 = new GradientPaint(0, 0, new Color(0, 0, 0), 0, height - 1, new Color(100, 100, 100));
bg = Color.LIGHT_GRAY;
RenderingHints rh = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHints(rh);
g2.setPaint(p1);
g2.draw(arrow);
g2.setPaint(bg);
g2.fill(arrow);
} |
Partager