Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Drawing a line outside the paint method

Posted on 2004-09-09
9
Medium Priority
?
275 Views
Last Modified: 2012-05-05
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
Comment
Question by:mte01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
9 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 12018587
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
 
LVL 3

Author Comment

by:mte01
ID: 12018644
>> 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
 
LVL 24

Expert Comment

by:sciuriware
ID: 12018720
I wonder what weird programming you are doing.
What would you instantiate more than you got?

;JOOP!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 1680 total points
ID: 12018771
>>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
 
LVL 3

Author Comment

by:mte01
ID: 12018782
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 1680 total points
ID: 12018808
void foo() {
    component.getGraphics().drawLine(.....);
}
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12018845
I give up. CEHJ can certainly handle this.

Good night.

;JOOP!
0
 
LVL 3

Author Comment

by:mte01
ID: 12018866
Excellant CEHJ that's all what I wanted!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12018935
8-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question