2012-12-05 46 views
2

我正在创建一个示例代码以显示在Javafx中设计的舞台,它不应该只需要最小化和最大化按钮关闭('X')按钮。舞台图标不可见

对于我们正在使用以下代码。

Stage stage = new Stage(); 
    // Here we have load it using JFXML 
    stage.initModality(Modality.WINDOW_MODAL); 
    stage.initStyle(StageStyle.UTILITY); 
    stage.setResizable(true); 
    if (title != null && !title.trim().isEmpty()) { 
     stage.setTitle(title); 
    } 
    stage.setWidth(w); 
    stage.setHeight(h); 
    stage.getIcons().add(new Image(Dialog.class.getResourceAsStream("/image/myicon.png"))); 
    stage.showAndWait(); 

现在我在舞台上设置的图标不可见。

我缺少什么?

回答

1

我假设Windows为OS(在MacOSX中显示图标)。在Windows下,StageStyle.UTILITY导致使用WS_EX_TOOLWINDOW在这种情况下,图标不显示。您可能需要使用另一个StageStyle。