Methods of styling GUI components in java - java

I'm creating a user interface for a java standalone desktop application but the forms, text fields and tables I built using javax.swing and java.awt packages look quite dull. Are there any methods by which these components can be stylized so that they look more appealing (like those beautiful websites made with css and javascript) ?

You can set the background, border, foreground, etc of these components. Consult the API for useful functions.
Or you can change the look and feel of your entire program. Recommended reading: http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

You could use Look and Feel, there are libraries that set your all your components with a defined style.
See this link http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html

Related

Nimbus-like look for JavaFX UI components

JavaFX allows styling of UI components via CSS. For seamless integration into an existing Swing application it would be nice to make the FX components look like Swing components with Nimbus look and feel. Are there any existing approaches to this? So far I haven't found anything.
An approach would be to code up some JavaFX CSS to make JavaFX look like nimbus, although it would be some work it would certainly be possible. Nimbus UI properties are published here:
http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html
Setting the variables that are defined in the caspian.css file to those in the link above will get you most except for the gradients, drop shadows and images.

Shiny GUI in Java

Is there any library I can use to create shiny user interfaces in Java?
e.g. The Intel Graphics & Media Control Panel is written in .Net.
Intel Graphics & Media Control Panel
I want to know how to create such UI in Java.
Well you can use and customize your UI with Swing.
Nowdays there is also JavaFx 2.0.
Also there are a lot of extensions like those from SwingLabs,JGoodies,Jide,Glazed List and the amazing Substance look& feel ,Steel Series etc.
Just google for this terms you get a lot of useful links.
http://download.oracle.com/javafx/
http://www.jgoodies.com/
http://swingx.java.net/
http://java.net/projects/substance/
http://harmoniccode.blogspot.com/
Be aware is not easy and out of the box functionality but you can do anything.
By default, Swing user interfaces use a look and feel called 'Metal'.
You could try making your own look and feel to accomplish something similar.

Information about swing components (java)

After learning python (cpython) and using this page to search for tkinter widgets' options, methods and patterns, I've started to develop in jython due to javax.swing module from java which can help me make platform-independent GUIs.
My question is: is there a page like the one I mentioned above which presents the options and methods of swing objects?
is there a page like the one I mentioned above which presents the options and methods of swing objects?
Yep (at least on a class level).
Have a look at the package summary for javax.swing (part of the API documentation):
Package summary: javax.swing
Also, here is a page with screen shots of most of the standard components:
A Visual Guide to Swing Components

java swing app with a custom titlebar?

Is there a way to write a Java Swing application with a custom chrome? Please take a look* at the frame for Microsoft's Zune 4.0 software.
I realize that colors, the shape of scroll bars, etc. are controlled by skins or looks and feels. Right now I'm trying to tackle the native window which houses the java components--the title bar mainly.
Thanks
(*) http://www.winsupersite.com/zune/zune4_shots.asp
By default the frame of a JFrame is native. This can be removed by calling Frame.setUndecorated. The Sun Window PL&F does not provide a title bar. You could hack aJInternalFrame so that it draws the frame, although that probably isn't going to be as easy as it may seem. Of course, if you are going the full custom route, you can draw whatever you want. From 6u10, Sun's JRE also provides APIs to make windows transparent and non-rectangular.
No part of a Swing component's look and feel is "native" in any way. Swing components are "lightweight", which means they are entirely drawn on the Java side, and not at all on the windowing system side.
To create custom "chrome" you create the UI delegates for one or more components. In yor case, you'd want to muck around with the delegates for JRootPane and JInternalFrame.
The Look and Feel of Swing apps are pluggable..that is it can change on the fly. You can create your own look and feel but its not a simple undertaking. To get started this tutorial explains. This article does a little more.
This project demonstrates what could be done. So its up to your imagination.

Skinning Java desktop applications?

Does anybody know a way to "skin" Java desktop applications. (Like Winamp skins, or skins for MirandaIM)?
I don't want to create my own look and feel.
Yes, there are a few ways this can be done, but I don't know anyone that is really simple. Have a look at Nimbus: The New Face of Swing, it contains a few examples. You can often override the look of components or just change the colors.
Some links:
Nimbus Colors
Skinning a Slider with Nimbus
Nimbus UIManager UIDefaults
And you can always change to another LaF, in example Substance.
We've successfully used the NimROD Look and Feel to 'skin' the Swing look & feel. It works well, has several 'themes' already written for it, and can be added in a few lines of code.
Swing has built-in dynamic look and feel support. If you are talking about desktop apps, you might want to start with Lesson: Modifying the Look and Feel.
Edit: If you are talking about a webapp, then absolutely use different .css to acheive a skinnable interface. CSS Zen Garden is a great example/tutorial on how the same page can look entirely different with a different .css file.
For a project that's still actively maintained in 2022 and allows skinning of Swing applications try FlatLaf
FlatLaf is a modern open-source cross-platform Look and Feel for Java
Swing desktop applications.
It looks almost flat (no shadows or gradients), clean, simple and
elegant. FlatLaf comes with Light, Dark, IntelliJ and Darcula themes,
scales on HiDPI displays and runs on Java 8 or newer.
The look is heavily inspired by Darcula and IntelliJ themes from
IntelliJ IDEA 2019.2+ and uses almost the same colors and icons.
Another modern look and feel active maintained in 2022 is https://github.com/vincenzopalazzo/material-ui-swing
It include also a way to develop a custom theme in an external jar, like this one https://github.com/material-ui-swing/DarkStackOverflowTheme

Categories

Resources