6

Any idea how to make the Java Swing file chooser look better on 2K displays where the windows font scaling is > 125%?

I am using ordinary code such as:

JFileChooser fc = new JFileChooser();
if (settings.currentdir != null)
   fc.setCurrentDirectory(new File(settings.currentdir));
int returnVal = fc.showOpenDialog((Window) holder);
if (returnVal == JFileChooser.APPROVE_OPTION) {

But the file chooser is only displaying tiny icons for the listed files and directories. I am using JDK 8. What is going wrong?

P.S.: Scope of the question is only Windows, not Unixes. On Windows, the two default L&F, they scale the font. But they don't scale icons. The application has to do that, since it might use a different bitmap resources for higher scales. It seems that JFileChooser is not coded this way.

But it might be that the JFileChooser can be instructed to do so. I don't see that the other question addresses icon size and the JFileChooser on Windows: How to set the DPI of Java Swing apps on Windows/Linux? The other question deals with font size, which is not an issue for the JFileChooser on Windows with one of the two Windows L&F.

Community
  • 1
  • 1
  • possible duplicate of [How to set the dpi of java swing apps on Windows/Linux?](http://stackoverflow.com/questions/15659044/how-to-set-the-dpi-of-java-swing-apps-on-windows-linux) – Joe Apr 22 '15 at 09:59
  • AFAIK, it's not possible right now. Please submit a bug/RFE at http://bugreport.java.com – Hendrik Jul 30 '15 at 14:03

1 Answers1

0

Just a quick idea while i came across this thread. You can try to deliver your own iconset:

new JFileChooser().setFileView(new FileView() {
        @Override
        public Icon getIcon(File f) {
            return fancy2kIconForExtension(StringUtils.substringAfterLast("."));
        }
    });

be careful to load your Icons from a Cache, as this method is called very often from inside JFileChooser, otherwise you end up reloading icon all the time.

gantners
  • 446
  • 4
  • 14
  • Ok, might give it a try soon. BTW: I noticed that a lot of apps have scaling issues, for example the Android SDK download manager looks awful on a 2K display and is nearly not usable. Strange that this is not addressed by Oracle, Google, etc.. –  Oct 06 '15 at 09:15