• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Applying affine transform to JPanel

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I am doing an application in which i need to scale a jpanel along with its components....for example, if i am having a jpanel of size 600x600 ,with some txtbox and buttons in it, and if i want to scale it to 300x300 with all its components visible,what shoud i do.....i heared it can be done using affine transform and i have no idea of how to use it.So please help me with some sample codes....

Thanks in advance

Arjun.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Affine transformations is something you use with graphics, not with components. You can change the size of components through their setMinimumSize/setPreferredSize/setMaximumSize methods. Of course, if there are any labels or other components that use fonts, then you will need to adjust the font size explicitly.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you're thinking about something like making a subclass of JPanel - and inside the paint() method, have a BufferedImage that you call super.paint() on (to paint the "normal" image of the JPanel), then scale the image, and paint that on the JPanel. This would only work for the "visual" part of components, but would mess up any "interactive" parts - i.e. the button would "look" bigger, but you would still need to click where it "really" was in it's smaller size to click it.
 
Arjun Palanichamy
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nathan,
You are right.I just want to see the JPanel along with all its components into a thumbnail view i.e,a scaled instance of that jpanel, and i dont want any component within that thumbnail view to perform any action like button click,etc.For example, if i am having a frame with two Jpanels , one containing several components in it and is of size 500x500,and other jpanel is empty and is of size 300x300.On clicking a button, i just want to show a thumbnail view of the first jpanel(that is ,the one containg components)in the second Jpanel.The thumbnail view may be 100x100.Please help me to do that with a sample code.

Thanks in advance
Arjun
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's some sample code I worked up that produces image thumbnails of JPanels...

Especially look at the "ScaledPanelIcon" inner class...

 
Arjun Palanichamy
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nathan....

Your source Code Work perfectly in my application, i am very happy same time Thanks to you again.
same time i want some another help plz ,i want the import PPT file in my java swing application,i seen the your previous reply POI webpage but i canot come to clear idea.i try to convert PPT file to (.sxi) and UNziped that i got One XML file but i canot modify it my applicaton. Plz if give any simple source code ....

Thanks in Advance.
Arjun
 
I found some pretty shells, some sea glass and this lovely tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic