Use CSS in Java Applications

You should look up javafx. You can attach a css file to a GUI. it is fairly easy to use. I can give you some example code if you want.

These are some good tutorials on how to use it:

I use eclipse to create a css file right click the project -> select new -> other -> CSS file

import javafx.application.*;
import java.text.*;
import java.util.*;
import javafx.event.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.input.*;
import javafx.stage.*;
import javafx.geometry.*;

 public class Display extends Application{

public static void main(String[] args){

public void start(Stage stage) throws Exception{

    HBox root = new HBox(); 

    Button button = new Button("button");
    Label  label = new Label("Label");

    root.getChildren().addAll(button, label);

    Scene scene = new Scene(root, 700,300);


<———————————CSS File——————————>

     -fx-background-color: linear-gradient(#383838, #838383);
     -fx-font-size: 11pt;

     -fx-text-fill: #e8e8e8;

-fx-background-color: linear-gradient(#dc9556, #ab4642);
-fx-background-radius: 100;

     -fx-background-color: white;
     -fx-background-radius: 0;

Leave a Comment