Strange behaviour with getBounds()


#1

Hi,

In a custom TabBarButton / paintButton, I’m doing this:

g.fillRect(getBounds().reduced(5, 0));

This fails drawing the rectangle for all but first button.
but if I do :

g.fillRect(5, 0, getWidth() - 10, getHeight()); 

It’s working perfectly.
I think the former is easier to understand than the later, but I don’t understand why it fails.
Also, while I’m not sure, I have the feeling the former slows the process start up (the window takes maybe 2 or 3 more seconds to display).


#2

Stupid me. getBounds is relative to the parent. Please ignore the question.


#3

I actually just added a new method today: getLocalBounds(), which does what you need there…