[FIXED] e4-Javafx: How to apply current theme to login dialog


My e4 javafx application displays login dialog before diplaying main window.

LifeCycleManager class

void postContextCreate(Application app, IEclipseContext econtext){  

    //display login dialog extends org.eclipse.fx.ui.dialogs.TitleAreaDialog
    LoginDialog dialog = new LoginDialog(null, "Login", "Login title", "Message", "");
    int response = dialog.open();             

    if (response != Dialog.OK_BUTTON) {

Dialog has default javafx styling (modena).

How do i get current theme and apply to this dialog?


I found out how to get stylesheets from current theme

import org.eclipse.fx.ui.services.theme.ThemeManager;

ThemeManager themeManager;

ObservableList<URL> stylesheets =  themeManager.getCurrentTheme().getStylesheetURL();

Next is to create dummy stage and add stylesheets to it;

Scene scene = new Scene(new HBox());
Stage stage = new Stage;
for (URL url : stylesheets) 

Then set stage as parent window (first parameter) to dialog

LoginDialog dialog = new LoginDialog(stage, "Login", "Login title",
                  "Message", "");

Dialog will copy stylesheets from parent stage and will add them to its own stage.

It works. But i doubt it is a “proper” way. There must be other solutions.

Answered By – Y Borys

Answer Checked By – David Goodson (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published