| Author |
Can I automatically scale a component and all its children?
|
Jane Jukowsky
Ranch Hand
Joined: Mar 28, 2009
Posts: 145
|
|
I am adapting my program for a 800x400 netbook. It's not easy. So I thought, why not just scale the whole thing, like this:
It works, almost... but of course that does not fool mouse events and such... besides, when mouse goes over any child component, it paints BIG.
So is there a better approach? Maybe someone has done it already?
Thanks
|
 |
Fabio Falci Rodrigues
Ranch Hand
Joined: Dec 01, 2007
Posts: 36
|
|
Very good question.
Do you already look for some LAF configurations?
|
SCEA5
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32604
|
|
|
Did you actually get that code to compile? Why are you using paint() not paintComponent()? Shouldn't the super. call be the first statement in the method?
|
 |
Jane Jukowsky
Ranch Hand
Joined: Mar 28, 2009
Posts: 145
|
|
Excellent idea, thanks! I will.
Campbell Ritchie wrote:Did you actually get that code to compile?
Yes, after taking away line 7
Why are you using paint() not paintComponent()?
Good point. Using paintComponent() now
Shouldn't the super. call be the first statement in the method?
Nope. Only in a constructor.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32604
|
|
|
No, in a constructor there is no super. call, only super(). You missed the . You should call super.paintXXX first in such a method, so as to return your component to a pristine state for the next round of painting.
|
 |
Jane Jukowsky
Ranch Hand
Joined: Mar 28, 2009
Posts: 145
|
|
|
Well, that's a mute point because BasicPaneUI.paint() is not doing anything; otherwise, it would need to be called after g.scale, not before.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
The (preferred) size of the component's haven't changed, just the way they look. The look&feel should fix that as well.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Jane Jukowsky
Ranch Hand
Joined: Mar 28, 2009
Posts: 145
|
|
Rob Prime wrote:The (preferred) size of the component's haven't changed, just the way they look. The look&feel should fix that as well.
That, and the whole mouse event dispatch thingy.
|
 |
 |
|
|
subject: Can I automatically scale a component and all its children?
|
|
|