• Post Reply Bookmark Topic Watch Topic
  • New Topic

further customizing JFIleChooser  RSS feed

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guided by this tutorial, i built my customized fileChooser

still, some words appear in english; as my language is portuguese, i'd like to customize the fileChooser further, but couldnt find any available methods
i played around with getApproveButtonText() but with no results

is there a way to alter those words?

thanks in advance
fileChooser.PNG
[Thumbnail for fileChooser.PNG]
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this method help?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the idea, but doesnt
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, we tried. Is the internationalisation thread on the Java™ Tutorials any help?
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can change the cancel button's caption by calling the following before you create the JFileChooser:
I couldn't find out which UIManager key should be used for the others, if any.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Well, we tried. Is the internationalisation thread on the Java™ Tutorials any help?

that's all its left if i cant find any other solution
Rob Prime wrote:You can change the cancel button's caption by calling the following before you create the JFileChooser:
I couldn't find out which UIManager key should be used for the others, if any.

great catch!: that worked nicely

i gave a view at JFileChooser's source code to grab any hint, but that's too much for me

thank you to both - great help
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with most of the Swing components is the look&feels. Half of the code is in the component's source file, the other half is in the look&feel's source code. If you want to investigate further you can check out javax.swing.plaf.basic.BasicFileChooserUI, that's the JFileChooser look&feel class for the default look&feel.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:The problem with most of the Swing components is the look&feels. Half of the code is in the component's source file, the other half is in the look&feel's source code. If you want to investigate further you can check out javax.swing.plaf.basic.BasicFileChooserUI, that's the JFileChooser look&feel class for the default look&feel.

i rushed into trying:

just to notice the method isnt publi

ok, i surrender, but no problem

thank you for your care
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the others (circled in the pic) would be

UIManager.put("FileChooser.lookInLabelText","abc1");
UIManager.put("FileChooser.filesOfTypeLabelText","abc2");
UIManager.put("FileChooser.fileNameLabelText","abc3");
UIManager.put("FileChooser.acceptAllFileFilterText","abc4");

replacing 'abc1..4' with whatever you want
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:the others (circled in the pic) would be

UIManager.put("FileChooser.lookInLabelText","abc1");
UIManager.put("FileChooser.filesOfTypeLabelText","abc2");
UIManager.put("FileChooser.fileNameLabelText","abc3");
UIManager.put("FileChooser.acceptAllFileFilterText","abc4");

replacing 'abc1..4' with whatever you want

fantastic!
how did you get it?
anyway i tried inside

acceptJustImagesFilterText
acceptJustimageFilterText
acceptJustimagesFilterText
and other similar combinations with no result and also exhausted my imagination :wink:
can you give me a last help?
thanks in advance
missing just images.PNG
[Thumbnail for missing just images.PNG]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'Just Images' should be what is returned from your file filter's
public String getDescription(){}
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
doesnt work ...
when i input

get JustImages
if a add a space between, i get that space too
anyway i tried both, but without result
dont understand it
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as i dont need custom icons for diferent image types, i have a turnaround:

and the second line Just Images) does not appear at all!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you're using the fileChooser's getDescription(), but it would be your file filter's getDescription that returns 'Just Images'

simple demo (change, or add to, the .gif, .jpg)

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
excelent, Michael!
now i have my chooser totally customized thanks to everyone who helped me

a great thank you to all of you
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
miguel lisboa wrote:fantastic!
how did you get it?

Apparently, these are used in MetalFileChooserUI.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!