2014-07-16 29 views
1

controlfx对话框,我怎么能在FXML控制器打开一个对话框,因为它需要stage的JavaFX如何FXML控制器

Dialogs.create() 
    .owner(---what should i write here---) 
    .title("Information Dialog") 
    .masthead("Look, an Information Dialog") 
    .message("I have a great message for you!") 
    .showInformation(); 

我加入以下jar

controlsfx-8.0.6_20.jar 
controlsfx-samples-8.0.6_20.jar 
fxsampler-1.0.6_20.jar 

请帮助我。

回答

1

所有者阶段该对话窗口将使用:

import org.controlsfx.dialog.Dialogs; 
import javafx.application.Application; 
import javafx.stage.Stage; 

public class Diag extends Application{ 

    @Override 
    public void start(Stage primaryStage) throws Exception { 
     Dialogs.create() 
     .owner(primaryStage) 
     .title("Information Dialog") 
     .masthead("Look, an Information Dialog") 
     .message("I have a great message for you!") 
     .showInformation(); 
    } 
    public static void main(String[] args) { 
     launch(args); 
    } 

} 

而且,你可能要称呼其为一个对话框,您不妨将其称为:

 Dialogs.create() 
     .owner(new Stage()) 
     .title("Information Dialog") 
     .masthead("Look, an Information Dialog") 
     .message("I have a great message for you!") 
     .showInformation(); 
相关问题