Reputation: 266
This blue appears around the edges of a window whenever that window has focus, and I want to get rid of it/style it another color.
Doing some research, it seems that the following code is the agreed upon solution for other nodes, but does not appear to work on the window as a whole.
.root{
-fx-focus-color: transparent !important;
-fx-faint-focus-color: transparent !important;
}
Upvotes: 1
Views: 288
Reputation: 1689
You can do it easily with this code on your start
method:
primaryStage.initStyle(StageStyle.UNDECORATED);
But the inconveniant this solution, is that remove all windows decoration, top menu bar too.
But you can add it again after deletion.
Code example:
package javafxdemo;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class JavaDemo extends Application {
public static void main(String[] args) {
launch(args);
}
class WindowButtons extends HBox {
public WindowButtons() {
Button closeBtn = new Button("X");
closeBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
Platform.exit();
}
});
this.getChildren().add(closeBtn);
}
}
@Override
public void start(Stage primaryStage) {
//remove window decoration
primaryStage.initStyle(StageStyle.UNDECORATED);
BorderPane borderPane = new BorderPane();
borderPane.setStyle("-fx-background-color: green;");
ToolBar toolBar = new ToolBar();
int height = 25;
toolBar.setPrefHeight(height);
toolBar.setMinHeight(height);
toolBar.setMaxHeight(height);
toolBar.getItems().add(new WindowButtons());
borderPane.setTop(toolBar);
primaryStage.setScene(new Scene(borderPane, 300, 250));
primaryStage.show();
}
}
source: https://stackoverflow.com/a/9864496/15186569
Upvotes: 0
Reputation: 266
Turns out this color is the accent color of Windows 10, and has nothing to do with JavaFX. Oh well, guess it will have to stay.
Upvotes: 1