cannot find symbol error. don't know why
843810Nov 2 2005 — edited Nov 2 2005Hello, I'm trying to write a button bean in the shape of a triangle but netbeans keeps throwing up a cannot find symbol error at my g.fillPolygon line. I've declared the number of sides and x and y coords.
Any ideas as to why this is happening would be greatly appreciated.
Here's the code:
package trianglebutton;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;
public class TriangleButtonBean extends JButton implements Serializable
{
private TriangleButtonBean graphicPolygon;
private Color buttonColour;
private Color textColour;
private String caption;
private int sides = 3;
private int size = 30;
private int centerX = 100;
private int centerY = 100;
public TriangleButtonBean()
{
super();
setPreferredSize(new Dimension(50,50));
setBorder(null);
buttonColour = Color.red;
textColour = Color.black;
caption = "";
}
public TriangleButtonBean(String acaption)
{
super();
setPreferredSize(new Dimension(50,50));
setBorder(null);
caption = acaption;
}
public void paintComponent(Graphics g)
{
String astring;
super.paintComponent(g);
g.setColor(buttonColour);
int centerX = graphicPolygon.getCenterX(); //Invoking getCenterX method
int centerY = graphicPolygon.getCenterY(); //Invoking getCenterY method
//int Xcoordinates [] = graphicPolygon.getPolygonXCoordinates(sides,size);
//int Ycoordinates [] = graphicPolygon.getPolygonYCoordinates(sides,size);
g.drawPolygon(centerX,centerY, sides); //Draw polygon using xcoord,ycoord and number of sides
g.fillPolygon(centerX,centerY, sides); //Fill poly
g.setColor(textColour);
if (caption.length() > 1)
{
astring = caption.substring(0,1);
}
else
{
astring = caption;
}
g.drawString(astring,22,27);
}
public void setButtonColour(Color acolour)
{
buttonColour = acolour;
repaint();
}
public Color getButtonColour()
{
return buttonColour;
}
public void setTextColour(Color acolour)
{
textColour = acolour;
repaint();
}
public Color getTextColour()
{
return textColour;
}
public void setCaption(String acaption)
{
caption = acaption;
repaint();
}
public String getCaption()
{
return caption;
}
// public void setCenterX(int xcoords)
// {
// centerX = xcoords;
// }
public int getCenterX()
{
return centerX;
}
// public void setCenterY(int ycoords)
//{
// centerY = ycoords;
// }
public int getCenterY()
{
return centerY;
}
public static void main(String[] args){
TriangleButtonBean agui = new TriangleButtonBean();
}
} // End of class