How To Customize A JFileChooser

爱⌒轻易说出口 提交于 2019-12-12 00:45:38

问题


I want to customize my JFileChooser so that instead of saying "Folder Name" at the bottom I want to set it to say "Picture Name" and at the text field I don't want that to change based on where i'm clicking, i want it to just stay blank the whole time. Anyway I could do this. basically I just want to customize my JFileChooser:


回答1:


The file chooser wasn't designed to be customized in this way. The proper solution would be to customize the UI of the file chooser.

For a hack you can try using Darryl's Swing Utils class. The example shows you can access the text field. Once you have the text field you could add a DocumentFilter to prevent the document from being updated. Or you could change the font color to white so you don't see the text.

The code to access the label would be similar. Just find the label containing the text you want to change.




回答2:


Add this code in main() method:

try{  
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e){}


来源:https://stackoverflow.com/questions/17630982/how-to-customize-a-jfilechooser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!