• 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

Change LookAndFeel in individual Swing components

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know there's a way to change the LookAndFeel in individual components. I like the standard Metal L&F but I like the Windows equivalent FileChooser better. I've set the program globally to the System's with "UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());" but I think the program looks terrible this way. If I can, I want the JFileChooser to be set to whatever System's default is. How can I do that?

Also, I read somewhere that it is technically illegal to distribute programs that use windows LookAndFeel. Will I be violating copyright laws or did I miss something?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try using the awt.FileDialog instead of the swing.JFileChooser
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*Using* the Windows LaF isn't the issue, it's the LaF itself (AFAIK). Your program can use any registered LaF, you just can't distribute the commercial LaF itself without a license.

(With the caveat I could be totally wrong about this.)
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the Swing forum.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) set the "other" LAF
2) create the component
3) reset the LAF to the default

 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Dunn wrote:try using the awt.FileDialog instead of the swing.JFileChooser


+1

I routinely provide an option to use java.awt.FileDialog instead of javax.swing.JFileChooser - it's more functional and better known to users.
 
Charles Mulloy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a method that I made if anyone's interested. I had some trouble at first but I got it working.




Simply modify the code so that fileString is passed to the file constructor you want to use. Now I gotta get the filter working. Thanks for the help every one!
reply
    Bookmark Topic Watch Topic
  • New Topic