![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2005
Posts: 4
Rep Power: 0
![]() |
Simple, yet annoying problem with Java Beans
Hi.
I am trying to make a button bean, well a set of them having arrows facing in directions (n,s,e,w). I am having great difficulty drawing the triangles which will represent the direction. I understand you use drawPolygon(i think) to do this but... In the help features of Net Beans 4.1, it says drawPolygon(int[],int[],int[]); When i go to try put this in, it totally does not like it. public LeftButtonBean() {
super();
setPreferredSize(new Dimension (50,50));
setBorder(null);
buttonColour=Color.black;
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(buttonColour);
g.drawPolygon();
}right i have that so far, i have left paramaters out of the draw polygon, which gives me "error, cannot find symbol method drawPolygon()". Right does anyone know how i should go about this, the help just confuses me with its representations of what the parameters needed are. Before anyone asks, i am a novice in Java programming. Please don't ask "why are you using java?" lol. Thanks in advance guys. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Why are you using java?
![]() No, serious now. The function drawPolygon() does not exist. The function drawPolygon(int[] xPoints, int[] yPoints, int nPoints) does. You can have two functions with the same name, but different parameters. You can give them completely different content, although it isn't recommended - it will be difficult to know by heart what parameter does what . |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Nov 2005
Posts: 4
Rep Power: 0
![]() |
can you give me an example of acceptable parameters lol? and example of it in use please?
|
|
|
|
|
|
#4 |
|
Professional Programmer
|
It wants 3 things:
int[] xPoints: A list of the X coords. int[] yPoints: A list of the Y coords. int nPoints: Number of points. |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Nov 2005
Posts: 4
Rep Power: 0
![]() |
Well i think i got the format for entering the parameters.
get no errors with it, but it displays nothing lol. i had declared; int xPoints[]=new int[num]; int yPoints[]=new int[num]; i had one for n, but it did'nt like that so i just entered a number, so when i call the method its like g.drawPolygon(xPoints,yPoints,num); Note num aint a var or anything lol, ive been playing around with numbers to try get it to display, but no joy :mad: |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|