4 ms·
How easy is it to get a native look and feel with JavaFX on the various desktop OSes? That is, Windows, Mac, and Linux (GTK and Qt)?
by cpburns2009 9y ago
How easy is it to get a native look and feel with JavaFX on the various desktop OSes? That is, Windows, Mac, and Linux (GTK and Qt)?
- fian 9y agoWhy do you think you need native look and feel? I have worked on a Java desktop app with Swing UI for over a decade. Mid 2000s we would get asked to "modernise" our applications UI, which really meant: "make it look like Windows XP". After Apple released iTunes, which totally ignored the native look and feel on Windows, people stopped caring so much as long as it looked ok and was intuitive. The boom in web apps with every SPA defining it own internal LAF through CSS and Javascript and the fad for flat UI components seems to have further watered down the arguments for conforming to a native LAF. I haven't played much yet with JavaFX so can't answer your actual question but I believe it is more flexible than Swing and Swing is already very customisable (though you sometimes need to create your own widgets by extending/implmenting off the default widgets).
- cpburns2009 9y agoI don't need a native look a feel and most people probably don't even care about it, but I do care and I definitely prefer it. I loathe modern flat themes which completely lack affordance. However, I would like my applications to look like they belong on the host OS even if it has an unfortunate flat theme. In order to practice what I preach, I'm looking for something that looks native for most cases that I can use for side projects and become proficient in. For my current project I chose SWT over Swing because SWT supports a native look on Linux (via GTK) while Swing doesn't (as far as I can tell). However, SWT is kind of clunky and I wonder if there are better options or if my previous research is out of date.
- librexpr 9y agoI recently tried to get a native look and feel with Swing, and this code worked on both linux and windows: try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch( ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e ) { } I originally found the UIManager line on StackOverflow, but I'm too lazy to go looking for the link.
- cpburns2009 9y agoHmm, either what I read was wrong or I misunderstood what it was saying. Thank you for the correction.
- consto 9y agoIn my limited experience, it's hard, but in most cases that isn't a problem. JavaFX is powerful, separating layout and styling from code via FXML and their CSS like language. If you want to style the application like a webapp it's a piece of cake, but if you want to style it to look native then you'll have to use stylesheets such as http://www.aerofx.org/ http://www.aerofx.org/ On the otherhand, with Swing all you need to do is add the following line: UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- cpburns2009 9y agoOkay, so for JavaFX you would need a specific style sheet for each OS version provided it doesn't support any theme customization. That's less than ideal, and a step backwards compared to Swing or SWT.
- alphaalpha101 9y agoDo you want it to look different on different platforms? If you do, you need to make it look different on different platforms. That's not a step back.