我有这个标签实现的例子:
public class JavaFX_uiTabPane extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("http://java-buddy.blogspot.com/");
Group root = new Group();
Scene scene = new Scene(root, 400, 300, Color.WHITE);
TabPane tabPane = new TabPane();
BorderPane mainPane = new BorderPane();
//Create Tabs
Tab tabA = new Tab();
tabA.setText("Tab A");
tabPane.getTabs().add(tabA);
Tab tabB = new Tab();
tabB.setText("Tab B");
tabPane.getTabs().add(tabB);
Tab tabC = new Tab();
tabC.setText("Tab C");
tabPane.getTabs().add(tabC);
mainPane.setCenter(tabPane);
mainPane.prefHeightProperty().bind(scene.heightProperty());
mainPane.prefWidthProperty().bind(scene.widthProperty());
root.getChildren().add(mainPane);
primaryStage.setScene(scene);
primaryStage.show();
}
}
我对如何使组件可关闭感兴趣。我想在右上角放一个小按钮,当按下它时,组件会从主舞台上移除。JavaFX可以做到这一点吗?