javafx: adding tabs dynamically when user opens a new file

浪尽此生 提交于 2019-12-12 02:02:37

问题


This is my edited question.. I want a new tab to be displayed in the same window. In the main window, i have a menu bar. Suppose the user clicks open, a new tab must be created in the same window below the menu bar and so on..

Kindly give me some pointers since I am a beginner in javafx. I appreciate your time and effort.


回答1:


use tabpane and add tabs to it programmatically

 TabPane tabPane = new TabPane();
 Tab mytab = new Tab("tab to be created programmatically");
 mytab.setContent(put your data here);
 tabPane.getTabs().add(mytab);

the tabpane should be in the window/node/scene that you are flirting with ...that's all



来源:https://stackoverflow.com/questions/26591505/javafx-adding-tabs-dynamically-when-user-opens-a-new-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!