swing getBounds offset hassle

i just making a bufferedimage version of a jPanel and its
components. i ran into a odd bit of hassle and wondered
if anyone here has come across it.

i have two frames. one has the layout in swing (using
a null layout manager and setBounds(x, y, width, height)
on the component. the second frame is a buffered
image of the jpanel and components in the other frame.

but when i ask for the bounds of the componects they
are not it the same place as they appear?

heres a picture of what i get.

http://topresult.tomato.co.uk/~ant/test/bswing.jpg

as u can see the jbutton is in one place; and i have
drawn where the jbutton thinks its bounds are :frowning: there
not the same… im at a loss…

note: jframe->jpanel->jbutton.

Hmm, there could be several reasons for this.

Not that JFrame[0, 0] is where the windowbar starts, not where the drawble area of your window starts.

So e.g. if you paint the image directly into the window it will be more in the left-upper corner than it was attended to.

Of course there could be many other reasons too, but I am sure that it has something to do with the windowbar-bounds-issue…

Good luck, lg Clemens

cool thanks. i poped eveything into a jwindows and it
all lines up- so i guess its the jframes offsets on title
bars ect :slight_smile: cheers…

Ye… well, it’s shifted by height of the title and widht of the border. Those bounds are relative to the component and not absolute.