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 / June 2007

Tip: Looking for answers? Try searching our database.

Drawing problems

Thread view: 
Click - 13 Jun 2007 13:21 GMT
Hello,

For my game, I create a JFrame and inside this frame I create a simple class
derived from JComponent. To paint my game, I use the paintcomponent method.
My game lies in a BufferedImage 640x480. At the start of the game, the
component size is 640x480. It works fine.
When I enlarge the window, the component is resized accordingly to the size
of the window, so in my paint method, I use an affinetransformop object to
resize the image when drawing it in the component with drawimage(myImage,
op, 0, 0).
Something very strange happens. Immediately after I resize the window, it
works fine : the image is draw, resized on the entiere surface of the
component.
But after that initial paint, the drawing process is clipped to the original
size of the component, 640x480. In that area, the image is perfectly drawn,
zoomed. But nothing is drawn out of that area.

Is there something I should do to insure that painting is allowed in the
entiere component? Have you heard of this problem before?

Francois
Click - 13 Jun 2007 13:52 GMT
"Click" <clicker@hotmail.fr> wrote :
> A lot of crap.

Sorry, I found my problem. It was my fault.

Francois
Andrew Thompson - 13 Jun 2007 14:12 GMT
>"Click" <clicker@hotmail.fr> wrote :
>> A lot of crap.
>
>Sorry, I found my problem. It was my fault.

Such comments are far more useful when you explain
what the solution was.  Don't forget, this is a discussion
forum, not a help desk.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Click - 13 Jun 2007 14:29 GMT
>>"Click" <clicker@hotmail.fr> wrote :
>>> A lot of crap.
>>Sorry, I found my problem. It was my fault.
> Such comments are far more useful when you explain
> what the solution was.  Don't forget, this is a discussion
> forum, not a help desk.

Sorry. But the mistake is so obvious that I am ashamed of it!
To force the repaint of my component, I used the "paintImmediately" method,
and I was using 0, 0, 640, 480 as parameters, not taking into account the
real size of the component. So of course, only this area was drawn.
When I told you this was a stupid mistake!

Francois
Andrew Thompson - 13 Jun 2007 14:49 GMT
>>>"Click" <clicker@hotmail.fr> wrote :
>>>> A lot of crap.
[quoted text clipped - 7 lines]
>and I was using 0, 0, 640, 480 as parameters, not taking into account the
>real size of the component. So of course, only this area was drawn.

Thanks for clarifying.  

>When I told you this was a stupid mistake!

(chuckle) I made one or two stupid mistakes today, a
couple the other day, and ..countless numbers of them
during my experiences with Java and other programming
languages over the years.

Hey, it's better to uncover a stupid mistake, than realise
you've discovered an 'incomputable problem', no?   ;-)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Patricia Shanahan - 13 Jun 2007 15:45 GMT
>>> "Click" <clicker@hotmail.fr> wrote :
>>>> A lot of crap.
[quoted text clipped - 8 lines]
> real size of the component. So of course, only this area was drawn.
> When I told you this was a stupid mistake!

This is useful data.

I thought, based on the symptoms, that the repaint was forcing the size,
but decided to leave the question for people who are more familiar with
GUI problems. Now I have confirmation that my inference was correct,
which will help me deal with similar issues in the future.

Patricia


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



©2008 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.