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.
Related
How to get the font properties of titlebar in JOptionPane. I am using linux OS system. We can get font properties of other java component using getFont API but as titlebar is OS dependent (native), what is the way to get font properties of titlebar ?
You can't really control titlebar decorations on Linux before Wayland, which is not generalized yet, and even in a Wayland world that will depend on the desktop environment, its toolkit, and how much leeway it gives to individual apps.
Probably a lost cause if you add the Java/native toolkit barrier. Java is not even using GTK3 yet, I doubt GTK2 will ever get more than minimal Wayland love and exploiting Wayland from GTK3 will probably require deeper support than just a minimal GTK2 glue replacement.
You may have more luck with SWT.
OpenJDK GTK3 support
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?).
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.
I developed a Java application in Netbeans, and I'm going to release it soon so I'm working on making it less ugly. Since I'm developing on a Mac, the GUI builder uses the Mac Look & Feel, which looks decent, but many of my users won't be using Macs. The default L&F is Nimbus, which looks fine except for the buttons, which have annoying borders that are not overridden by the manually setting the borders (you can see how the manual borders look in the image). With the manually set borders, the Nimbus L&F adds its own odd border inside the border I made, which just looks idiotic. Without the manually set borders, Nimbus's borders overlap in visually unappealing ways, and in order to avoid overlap I have to space the buttons really far apart, which I also don't like.
I tried using the other L&Fs available in Netbeans (Metal and something else), but they're just too ugly to stand.
Basically, I would like some advice on how to customize the way buttons look in this application. I don't want to write a button drawing function from scratch or design my own images. I just want a way to change the settings so things don't look stupid. I read in various places that the Substance L&F is good, but I can't find where to download it anywhere. If someone could link me to a download page for Substance or recommend another popular, simple and not stupid-looking L&F, I would greatly appreciate it.
Yeah pretty much all the L&Fs you'll find in Netbeans are worse than the default. The program will use the default Look & Feel of the operating system - so if it's being run on Windows it will have the "Windows-esce" buttons and fonts and on Mac will have the Mac style.
It all depends on what you're looking for. If you're application is meant to be professional and you don't mind it having different styles depending on the OS of the user then I'd leave it as default. It lends familiarity to your program which can truly make the user feel much more comfortable.
If you're after an indetical look for all users then, as you know, you just need to include the L&F with your program. I couldn't find a download for Substance but there are a few L&F's here - both commercial and free.
http://www.java2s.com/Product/Java/Swing/Look-And-Feel-LaF.htm
My goal is to make a simple GUI which almost look like this attached screenshot.
But while using Awt, Swing i have never found yet such combo/buttons nor i have found something like transparent window which showing my desktop background.
I am very desperate to make something similar, but i am not sure which framework i can use?
Can i do this above UI, with GWT? or is there something else?
Java has always supported translucent windows on Mac (from at least OS X 10.4 but probably way before that too).
However on Windows you need at least Java 1.6.0_10 to be able to do translucent windows directly from Java.
If for whatever reason you're stuck with an older Java you can use JNA. They've got examples as to how to create translucent windows on OS X, Windows and Linux and these examples work even on older JVMs.
As I type this JNA is located here:
https://github.com/twall/jna
Here's the code for their alpha/translucent example (where you can drag a picture with an alpha channel, like a PNG with an alpha channel and then choose the opacity):
https://github.com/twall/jna/tree/master/contrib/alphamaskdemo/com/sun/jna/contrib/demo
Now what you want to do can be done but there are gotchas: you need to be careful about several things. For example mouse events: if you want catch them or not when they happen on an area that is "fully transparent" (if you want to catch them, you can cheat and make your translucent window nearly --but not fully-- transparent).
What you want to do is a bit like a HUD: there are definitely HUDs done in Java but as far as I know they weren't build using GUI builder tools. You'll probably have to code it manually (or at least some part of it manually).
See this: How to Create Translucent and Shaped Windows