Drawing problems

C

Click

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
 
C

Click

Andrew Thompson said:
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
 
A

Andrew Thompson

Click said:
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.

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? ;-)

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200706/1
 
P

Patricia Shanahan

Click said:
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!

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top