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
Solved

Drawing a line outside the paint method

Posted on 2004-09-09
9
270 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
  • 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 420 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 420 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
simple java question 3 59
servlet filter example 37 72
Java: How do I open the default windows program for a given file type 3 39
ejb on wildfly 5 30
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

837 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