1

UPDATE java 8 jdk works with title bar. It's only an issue with java 11 jdk

I'm learning javafx. I'm starting with simple applications, however I can't seem to get a title bar. I'm using linux (elementary os). I've tried stage.initStyle(StageStyle.DECORATED); I can't seem to find others which have had this issue. I only find those who are trying to remove the title bar. Maybe it's an operating system issue?

I'm using jdk 11 with javafx11

package sample;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Main extends Application implements EventHandler<ActionEvent> {
    Button button;

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("title of window");
        button = new Button();
        button.setText("click me");

        StackPane layout = new StackPane();
        layout.getChildren().add(button);

        Scene scene = new Scene(layout, 300, 250);



        primaryStage.setScene(scene);
        primaryStage.show();
    }

    @Override
    public void handle(ActionEvent event) {

    }
}

enter image description here

Nathan Rigg
  • 141
  • 1
  • 6
  • Are you using [tag:javafx-8] or [tag:javafx-11]? Please remove one of these tags – MTCoster Dec 09 '18 at 15:27
  • 1
    What OS are you using? In Ubuntu 18.04 window opens with decorator: https://i.imgur.com/iJ9DIeE.png – RoninDev Dec 09 '18 at 15:42
  • javafx-11, 8 tag removed. Thanks for pointing that out – Nathan Rigg Dec 09 '18 at 15:48
  • RoninDev I'm using elementary 0s 5.0 which is based on ubuntu 18.04. Hmm. Well thanks for testing that. Maybe this is a bug with elementary? – Nathan Rigg Dec 09 '18 at 15:50
  • I have not mentioned that you use java11. My sample is ok using java8 – RoninDev Dec 09 '18 at 16:04
  • 1
    Since you're using Linux, try using GTK version 2 via `-Djdk.gtk.version=2`. See [this answer](https://stackoverflow.com/a/53351433/6395627) for more details. – Slaw Dec 09 '18 at 16:06
  • I just tried java 8 and worked for me as well with title bar. Thanks for discovering that. At least I know that works – Nathan Rigg Dec 09 '18 at 16:13

0 Answers0