Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Graphics

Thread view: 
zajekurwabiscie@o2.pl - 25 Feb 2007 18:23 GMT
Hi, my name is Janek and I have a small question about
paintComponent(Graphics g) - to draw for example LINE I should use
g.drawLine but what if I have my own Graphics created somewhere else.
More precisely I have:

BufferedImage backimage;
Graphics2D offScreen;
offScreen = backimage.createGraphics();
offScreen.drawLine(0,0,10,10);

and I would like to display it using paintComponent(Graphics g).
How can I do it ?
Andrew Thompson - 25 Feb 2007 18:49 GMT
On Feb 26, 5:23 am, zajekurwabis...@o2.pl wrote:
..
> BufferedImage backimage;
..
> and I would like to display it using paintComponent(Graphics g).

g.drawImage(backimage, 0, 0, null);

Andrew T.
zajekurwabiscie@o2.pl - 25 Feb 2007 19:12 GMT
>  g.drawImage(backimage, 0, 0, null);
>
> Andrew T.

But I want to draw not only the image but also all changes done to
that image :

BufferedImage backimage;
Graphics2D offScreen;
offScreen = backimage.createGraphics();
offScreen.drawLine(0,0,10,10);                   <-------------- I
need this too !!!!!!!!
zajekurwabiscie@o2.pl - 25 Feb 2007 19:14 GMT
I want to draw not only the image but also all applied changes :

BufferedImage backimage;
Graphics2D offScreen;
offScreen = backimage.createGraphics();
offScreen.drawLine(0,0,10,10);           <------------- I need to draw
it too !!!!!!!
Andrew Thompson - 25 Feb 2007 19:46 GMT
On Feb 26, 6:14 am, zajekurwabis...@o2.pl wrote:
> I want to draw not only the image but also all applied changes :

Did you try what I suggested?
Did it fail to do what you wanted?
Can you supply an SSCCE* that fails
the same way?

* <http://www.physci.org/codes/sscce.html>

Andrew T.
zajekurwabiscie@o2.pl - 26 Feb 2007 00:54 GMT
U were right !!! Sorry for my luck of trust. I had a misteke !
BTW it's not natural - I mean creating a graphics object from image
( offScreen = backimage.createGraphics();  )
then using n changing Graphics object but changes are applied to
image :|

This line suggests that offScreen is created from backimage n this
image is no longer involved
offScreen = backimage.createGraphics();
but than we paint or save backimage :| WHY ?? HOW ??
Andrew Thompson - 26 Feb 2007 04:04 GMT
On Feb 26, 11:54 am, zajekurwabis...@o2.pl wrote:
> U were right !!!

Please note that while some abbreviations
are OK for this group, and others are needed,
abbreviations like 'u', and 'plz' generally
are not liked.  Please attempt to spell short
words like 'you' properly.  Also, only one '!'
gets the point across!

> Sorry for my luck of trust.

Why should we trust each other?  Tests
are always better, and note that I would
not expect someone who does not know me,
to take anyhting I say 'on trust'.

>..I had a misteke !
> BTW it's not natural - I mean creating a graphics object from image
[quoted text clipped - 5 lines]
> image is no longer involved
> offScreen = backimage.createGraphics();

The word 'create' does suggest (to me) that
the Graphic object is 'newly created' and
therefore 'separate' from the BufferedImage,
but it would probably be better called
'getGraphics', ainsce it gets *the* graphics
object of te image, and all changes (lines,
colors, circles) to the graphic, are stored
in the image.

> but than we paint or save backimage :| WHY ?? HOW ??

It shows the Image, as it was after the
last changes made to the graphic object.

(And last note, ALL CAPS is equivalent
to SHOUTING.  Please don't shout at me,
because I have a hangover..)

Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.