• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Drawing a line outside the paint method

Hey Experts!

Well, I guess the question explains itself....In the paint method you can easily draw a line with the Gaphics object g and the method draw line; however, outisde it, if I want to draw a line I can't  do that because Graphics is an abstract class, and thus I cannot instantiate objects of its type to draw lines. Is there a simple way to draw a line inside a function?
0
mte01
Asked:
mte01
  • 3
  • 3
  • 3
2 Solutions
 
sciuriwareCommented:
You must not create a Graphics object yourself! paint gives you a reference
to a Graphics object. The object is surely "bigger" that the abstract class,
but the abstract class is just a kind of guarantee that some methods
will be implemented. Why not call another method with such an object as an argument?

;JOOP!
0
 
mte01Author Commented:
>> Why not call another method with such an object as an argument?

I tried, but I couldn't (you have to instantiate something at some point)...how could you do that??
0
 
sciuriwareCommented:
I wonder what weird programming you are doing.
What would you instantiate more than you got?

;JOOP!
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CEHJCommented:
>>Is there a simple way to draw a line inside a function?

You can draw a line from anywhere as long as you've got a reference to a Graphics context
0
 
mte01Author Commented:
I didn't understand your last comment.....anyway let's go back to our main point:

>> Why not call another method with such an object as an argument?

How could you do that? and how could that help in drawing a line inside a user function (which is just all what I want to do)
0
 
CEHJCommented:
void foo() {
    component.getGraphics().drawLine(.....);
}
0
 
sciuriwareCommented:
I give up. CEHJ can certainly handle this.

Good night.

;JOOP!
0
 
mte01Author Commented:
Excellant CEHJ that's all what I wanted!
0
 
CEHJCommented:
8-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now