Hey everyone,

After looking around for 2 days I succeeded in making a hexagon button! It reacts fine except for one thing:

If you mouse-over the polygon it re-draws the shape with a small offset on the x/y making it appear double! I have no clue what is causing this since i've overridden practically every method:

import javax.swing.*;
import java.awt.event.MouseEvent;  
import java.awt.event.MouseListener; 

import java.awt.*;
import java.awt.event.*;
public class Hexaton extends JButton implements MouseListener {
	private int x, y,l;
	private Polygon shape;
	private Color kleur;
	public Hexaton(int x, int y, int length){
		this.shape = new Polygon();
		this.x = x;
		this.y = y;
		this.l = length;
	public void initialize(){
		Point p1, p2, p3, p4, p5, p6;
		p1 = new Point(x+(int)(Math.abs(Math.sin(60))*l),y);
		p2 = new Point(p1.x+l, p1.y);
		p3 = new Point(p2.x+(int)(Math.abs(Math.sin(60))*l), p2.y+(int)(Math.abs(Math.cos(60))*l));
		p4 = new Point(p3.x-(int)(Math.abs(Math.sin(60))*l), p3.y+(int)(Math.abs(Math.cos(60))*l));
		p5 = new Point(p4.x-l, p4.y);
		p6 = new Point(p5.x-(int)(Math.abs(Math.sin(60))*l), p5.y-(int)(Math.abs(Math.cos(60)*l)));
		System.out.println("Coordinates: "+"("+p1.x+","+p1.y+"), "+"("+p2.x+","+p2.y+"), "+"("+p3.x+","+p3.y+"), "
				+"("+p4.x+","+p4.y+"), "+"("+p5.x+","+p5.y+"), "+"("+p6.x+","+p6.y+"), ");
		System.out.println("Cos: "+Math.abs(Math.cos(60)*l));
		System.out.println("Sin: "+Math.abs(Math.sin(60)*l));
		this.shape.addPoint((int) Math.round(p1.getX()),(int) Math.round(p1.getY()));
		this.shape.addPoint((int) Math.round(p2.getX()),(int) Math.round(p2.getY()));
		this.shape.addPoint((int) Math.round(p3.getX()),(int) Math.round(p3.getY()));
		this.shape.addPoint((int) Math.round(p4.getX()),(int) Math.round(p4.getY()));
		this.shape.addPoint((int) Math.round(p5.getX()),(int) Math.round(p5.getY()));
		this.shape.addPoint((int) Math.round(p6.getX()),(int) Math.round(p6.getY()));
		setPreferredSize(new Dimension((int)shape.getBounds().getMaxX(), (int)shape.getBounds().getMaxX()));
	public boolean contains(int x, int y) {
        return this.shape.contains(x, y);
	public void paintBorder(Graphics g){
	protected void paintComponent(Graphics g) {
        Graphics2D gCopy = (Graphics2D) g.create();

	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub

	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub

	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub

	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub

	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
Any pointers would be greatly appreciated!