• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I automatically scale a component and all its children?

 
Jane Jukowsky
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very good question.
Do you already look for some LAF configurations?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20613
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The (preferred) size of the component's haven't changed, just the way they look. The look&feel should fix that as well.
 
Jane Jukowsky
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic