This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Change LookAndFeel in individual Swing components  RSS feed

 
Charles Mulloy
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try using the awt.FileDialog instead of the swing.JFileChooser
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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.)
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Swing forum.
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) set the "other" LAF
2) create the component
3) reset the LAF to the default

 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • 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
  • 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!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!