cannot call a paint function across classes?  
Author Message
Dilbert





PostPosted: 2003-11-12 18:58:00 Top

java-programmer, cannot call a paint function across classes? Just wondering if this is possible, as im having no luck working it out, no
matter what ive tried so far..

I have 2 classes, lets call them gP and kP. in gP ive got this function:

public void paint55(java.awt.Graphics graphics) {
Dimension d=getSize();
graphics.setColor(Color.RED);
graphics.fillRect(0, 0, (int)d.getWidth(), (int)d.getHeight());
graphics.setColor(Color.BLACK);
//call another function here
}


now, in the kP class, im using a jComboBox, the combo box works fine, but i
want to try and call that function from it
Ive tried

gP.paint55();
ive tried referencing it as gP paint55();

Just cant work it out, any ideas?

Thanks



 
Thomas Fritsch





PostPosted: 2003-11-12 23:26:00 Top

java-programmer >> cannot call a paint function across classes? Dilbert wrote:

>Just wondering if this is possible, as im having no luck working it out, no
>matter what ive tried so far..
>
>I have 2 classes, lets call them gP and kP. in gP ive got this function:
>
"gP" is the name of your *class*, if I understood you correct.

>
> public void paint55(java.awt.Graphics graphics) {
> Dimension d=getSize();
> graphics.setColor(Color.RED);
> graphics.fillRect(0, 0, (int)d.getWidth(), (int)d.getHeight());
> graphics.setColor(Color.BLACK);
> //call another function here
>}
>
>
>now, in the kP class, im using a jComboBox, the combo box works fine, but i
>want to try and call that function from it
>Ive tried
>
>gP.paint55();
>
You call this function as if "gP" were the name of a *variable* in your
code.

>ive tried referencing it as gP paint55();
>
>Just cant work it out, any ideas?
>
>Thanks
>
>
It looks like you did not yet grasp the difference between Class and Object.
I suggest working through an introductory book on Java programming.

/Thomas