Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 6th, 2005, 5:52 AM   #1
rross46
Newbie
 
Join Date: Nov 2005
Posts: 4
Rep Power: 0 rross46 is on a distinguished road
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.
rross46 is offline   Reply With Quote
Old Nov 6th, 2005, 8:30 AM   #2
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
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 .
Polyphemus_ is offline   Reply With Quote
Old Nov 6th, 2005, 10:54 AM   #3
rross46
Newbie
 
Join Date: Nov 2005
Posts: 4
Rep Power: 0 rross46 is on a distinguished road
can you give me an example of acceptable parameters lol? and example of it in use please?
rross46 is offline   Reply With Quote
Old Nov 6th, 2005, 4:42 PM   #4
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 310
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
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.
andro is offline   Reply With Quote
Old Nov 7th, 2005, 8:16 AM   #5
rross46
Newbie
 
Join Date: Nov 2005
Posts: 4
Rep Power: 0 rross46 is on a distinguished road
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:
rross46 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:30 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC