儿童窗口与最大化和关闭按钮

时间:2013-05-14 03:48:12

标签: javafx-2 parent-child

仍然在这里学习......我正在尝试创建一个应用程序窗口(阶段),我可以将其称为子窗口。父母自然带有最小化,最大化和关闭(x)按钮,但是当我添加一个子窗口时,我无法移动或调整孩子的大小,而且它没有标准的三个按钮。

这里的代码我一直在玩弄:

// Stage ventasStage = new Stage(); // originally the child was stand alone and had the standard 3 buttons
AnchorPane ventas = (AnchorPane) FXMLLoader.load(Punto_de_Venta.class.getResource("VentasGUI.fxml"));
//    Scene ventasScene = new Scene(ventas); //"stage" and "scene" removed to add "getChildren"
home.getChildren().add(ventas); 

getChildren让我的新窗口成为父场景的一部分,但我无法获得3个标准按钮。我假设按钮被添加到舞台而不是添加到AnchorPane(这是getChildren在这里得到的)但是getChildren不能用于舞台,对吧?那么如何让父母可以互换,每个孩子都可移动,可调整大小并且有标准的三个按钮(最小化,最大化和关闭)?

1 个答案:

答案 0 :(得分:0)

三个按钮对应一个标准窗口(由OS提供),它是Stage。场景 - 是一个对象,它对应于场景图,是舞台的一个属性。因此,使用stage.setScene(..)将Scene设置为Stage。 Stene有一个根节点(通常是某种布局)。对我来说,你应该使用Scene.setRoot(...)方法。

BTW,关于Stage:你可以使用stage.init ...()来使用不同的装饰模式和不同类型的模态。