• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can I automatically scale a component and all its children?

 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very good question.
Do you already look for some LAF configurations?
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic