JFilechooser appearance - java

In my swing application, I have set the UI Look and Feel as:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
And it works well on Windows. Inside, the application, the user has to select files using the JFileChooser. The JFileChooser appearance on windows is again the native one. But not on Mac.
The screenshot of the JFileChooser Panel:
But instead, I prefer something like this: (This one is taken from upload option in gmail)
What should I change the UIManager to or anything else??

Several alternatives include these:
java.awt.FileDialog, illustrated here.
A custom ChooserUI, shown here.
A completely custom implementation; several variations are shown here.

On MacOS, you can use the FileDialog which looks like what you are describing. The drawback is that it is a lot less configurable.

I have experienced a lot of troubles when migrating from Java 6 to Java 8 since with my Java application I have to open some proprietary file bundles.
FileDialog still gives the better LookAndFeel, but treats the bundled files as if it were directories. A first fix to this is to set FileDialog to select directories, which still allows to navigate inside the file-bundle, but as well allows to select the bundle as a whole.
System.setProperty("apple.awt.fileDialogForDirectories", "true");
Not quite happy by the solution I tried other options, including the VAqua LookAndFeel for macOS which looked really great but sometimes didn't display me all the UI Elements (some JTree were hidden at startup, and JFileChooser did look great, but still didn't show me the Network drives in the sidebar).
Finally I found a simple property that - when set - allows to use FileDialog as it was under Java 6. Of course, if we want to select files and not directories, the line above must be deleted.
System.setProperty("apple.awt.use-file-dialog-packages", "true");
Found this one in an old example project about Dialog personalization

The file chooser implementation for Windows, Linux and Mac is not 100% right for any OS
Unfortunately if you really want this you need to look for a replacement for JFileChooser or you need to write your own look and fee.
Java has trouble keeping up with the OS changes.

Related

Change icon of executable exe file

I have created an executable file using NetBeans 8.0.2 (the standard JDK), following the instructions on this website about native packaging: https://netbeans.org/kb/docs/java/native_pkg.html.
Now, how do I change the icon of the exe installer file from the standard Java coffee cup, to my own custom icon? (I was able to change the icon that displays in the installed application's top left window, by directly coding the frame's image resource in the source code of my application).
However I want my custom icon to also be displayed on the actual exe installer file, and the installed application's desktop icon. I had the same issue when I tried an MSI file, instead of and EXE file. I tried searching for other solutions, but none of them have worked for me. I even tried Resource Hacker, but that didn't work for me. How do other people achieve this (seemingly simple/straightforward) thing? I would imagine this requirement is in high demand.
Yes, after looking at a quick video demo of InstallBuilder:
https://www.youtube.com/watch?v=wMXWq2b5IxM
I think this is the easiest solution for customising (plus it offers a whole help of features). It looks like a high-end product. HOWEVER, it is pricey - starting at around $500, but they do have a free evaluation download, so I'll start there. There are some other free tools out there, but InstallBuilder seems to be the most user-friendly I've seen so far.

update windows shortcut icon in Java

How can one change the icon image of a pre-existing shortcut through java? I do not want to change the icon image of a java executable, but have a java program that changes a shortcut's icon image.
I know I can manually change the icon image by right clicking on a shortcut and going to properties->shortcut->change icon, but I would like to do this through java.
Its impractical do this in pure java yourself, although the lnk-file format is documented by microsoft (http://msdn.microsoft.com/en-us/library/dd871305.aspx), but since it originated with Win95 it underwent significant extensions and redefinitions over the years. Implementing this seems like a daunting task.
You can try to find a library that implements it for you, e.g. http://ovanttasks.sourceforge.net/ov-native/ may do what you want.
The alternative would be to use existing Windows API's to do the job (See How do you create (and read) windows shortcut(.lnk file) in Java?).

Program win32 installer from scratch

I want to recreate a basic Windows installer, like the ones nullsoft or innosetup produce, but in Java.
Unfortunatly, I'm a bit lost for some points.
First of all I'd have to copy the software data to Program Files, this point seems clear to me. But I suppose that I would also have to send some information to the OS, for instance to have my program's uninstaller listed in the Programs and Features part of the Control Panel.
And I also need to create some icons on the desktop and put an entry on start menu.
There are probably a ton of other things I forgot, so what are they, and what is the best way to do these in java ?
Take a look at IzPack, I think is what you are looking for ...
If you don't like it as it is, you can take a look at the source code at the official git repo.

How to write a Icon Handlers for explorer.exe in Java

First of all, I'm a java developer and I am currently working on a small application for Windows only.
In my application, I wish to do as dropbox or tortoise do : add an overlay icon in windows explorer to show the user some state of files managed by my application. (I want the icon of the file change depending on some data stored in the file)
Is it possible to do so in Java ? Do you have examples ?
If it is doable but not efficient, how would you do instead ?
Thanks in advance
Fluminis
It would be possible to do this via JNI - you would need to hook into the Windows registry and from there into the Explorer shell, probably into the various file classes held there.
However, unless you have at least some familiarity with C++ and the windows API, you are unlikely to be able to achieve this.
Java is not the ideal language for what you want to do.

Alternative to JFileChooser on Linux?

I don't like this ugly FileChooser layout in Linux.
This layout is used by any other program and is MUCH more beautiful.
Is this layout available in Java? If so, how?
Update: this project is dedicated to solving the problem.
I do not believe this is a duplicate. The suggested solutions in the other questions do not help the situation in Linux (GTK at least).
AWT's FileDialog looks different than JFileChooser, but really just as strange. It does not look like the file choosers of native GTK applications.
XFileDialog is Windows-only and falls back on JFileChooser in GTK.
VFSJFileChooser does not have improved GTK LAF as a goal.
Unfortunately I do not know of any file chooser that looks native in GTK. Hopefully someone else does.
The gtkjfilechooser is not working with newer JDK's like JDK7. This was reported 2011, but is not fixed yet.
On the other side, the AWT FileDialog has been improved with Java 7 - including multiple file selection. Check linked JavaDoc for .
AWT's FileDialog looks different than JFileChooser, but really just as strange. It does not look like the file choosers of native GTK applications.
Talking about FileDialog of JDK7, this is not true anymore. Now, it looks exactly like the native one.
Btw., the same issue occurs on OS X, the it's JFileChooser doesn't look very native too. Apple recommends the usage of FileDialog instead of JFileChooser:
Although each has its advantages, java.awt.FileDialog makes your
applications behave more like a native Mac app. This dialog
[FileDialog], [...], looks much like a Finder window in OS X.
[...]
The Swing dialog, [...], looks much less like an OS X dialog.
[...]
Unless you need a functional advantage of JFileChooser, use FileDialog instead.
(Source)
Last sentence seems to be common (for all *NIX?) between Linux and OS X. So finally:
If you don't have a (functional) reason for JFileChooser, use AWT's FileDialog instead.

Categories

Resources