Javafx 2 javafx2.x:选项卡窗格中的Stage

Javafx 2 javafx2.x:选项卡窗格中的Stage,javafx-2,tabpanel,Javafx 2,Tabpanel,我需要通过单击按钮(如下图)在选项卡窗格中显示一个或多个阶段 我的目标是有一个类似于JInternalFrame的情况:如何实现这一点? 我无法将阶段作为子项添加到选项卡窗格 如果这不可能,还有什么其他解决方案?我想在舞台上用拼图 谢谢 PS我正在使用Win7、NetBeans 7.4测试版(构建201307092200)、SceneBuilder 1.1 编辑:以下是它在一些VFXWindows css更改后的外观 有一件事值得注意:我必须添加一个节点(在我的例子中是一个prefSize(

我需要通过单击按钮(如下图)在选项卡窗格中显示一个或多个阶段

我的目标是有一个类似于JInternalFrame的情况:如何实现这一点? 我无法将阶段作为子项添加到选项卡窗格

如果这不可能,还有什么其他解决方案?我想在舞台上用拼图

谢谢

PS我正在使用Win7、NetBeans 7.4测试版(构建201307092200)、SceneBuilder 1.1

编辑:以下是它在一些VFXWindows css更改后的外观

有一件事值得注意:我必须添加一个节点(在我的例子中是一个prefSize(0,0)的HBox),否则我无法移动或调整绘制的第一个窗口的大小,只有第一个窗口


最后,我找不到设置windows全屏(最大化)的方法。

在这里,我从选项卡内部放置了一个窗口示例,我只是修改了

导入javafx.application.application;
导入javafx.event.ActionEvent;
导入javafx.event.EventHandler;
导入javafx.scene.Group;
导入javafx.scene.scene;
导入javafx.scene.control.Button;
导入javafx.scene.control.Label;
导入javafx.scene.control.Tab;
导入javafx.scene.control.TabPane;
导入javafx.stage.stage;
导入jfxtras.labs.scene.control.window.CloseIcon;
导入jfxtras.labs.scene.control.window.minimizecon;
导入jfxtras.labs.scene.control.window.window;
公共类WindowInTab扩展了应用程序{
专用静态整数计数器=1;
私有void init(阶段primaryStage){
TabPane TabPane=新建TabPane();
Tab=generateTab(“窗口…”);
Tab anotherTab=generateTab(“更多窗口”);
tabPane.getTabs().addAll(选项卡,另一个选项卡);
primaryStage.SetResizeable(真);
设置场景(新场景(tabPane,600500));
}
专用选项卡生成器选项卡(字符串选项卡名称){
Tab Tab=新选项卡(tabName);
最终组根=新组();
tab.setContent(根目录);
按钮按钮=新按钮(“添加更多窗口”);
root.getChildren().addAll(按钮);
setOnAction(新的EventHandler(){
@凌驾
公共无效句柄(ActionEvent arg0){
//创建标题为“我的窗口”的窗口
窗口w=新窗口(“我的窗口”#“+计数器);
//将窗口位置设置为10,10(画布内的坐标)
w、 setLayoutX(10);
w、 setLayoutY(10);
//定义初始窗口大小
w、 setPrefSize(300200);
//要么向左
w、 getLeftIcons().add(新建CloseIcon(w));
//…还是向右
w、 getRightIcons().add(新的最小化图标(w));
//添加一些内容
w、 getContentPane().getChildren().add(新标签(“内容…\n窗口的“#”+”计数器++);
//将窗口添加到画布
root.getChildren().add(w);
}
});
返回选项卡;
}
public double getSampleWidth(){return 600;}
public double getSampleHeight(){return 500;}
@凌驾
public void start(Stage primaryStage)引发异常{
初始阶段;
primaryStage.show();
}
公共静态void main(字符串[]args){launch(args);}
}


我不知道这是否正是您想要的。希望能有所帮助!

在这里,我从选项卡内部放置了一个窗口示例,我只是修改了

导入javafx.application.application;
导入javafx.event.ActionEvent;
导入javafx.event.EventHandler;
导入javafx.scene.Group;
导入javafx.scene.scene;
导入javafx.scene.control.Button;
导入javafx.scene.control.Label;
导入javafx.scene.control.Tab;
导入javafx.scene.control.TabPane;
导入javafx.stage.stage;
导入jfxtras.labs.scene.control.window.CloseIcon;
导入jfxtras.labs.scene.control.window.minimizecon;
导入jfxtras.labs.scene.control.window.window;
公共类WindowInTab扩展了应用程序{
专用静态整数计数器=1;
私有void init(阶段primaryStage){
TabPane TabPane=新建TabPane();
Tab=generateTab(“窗口…”);
Tab anotherTab=generateTab(“更多窗口”);
tabPane.getTabs().addAll(选项卡,另一个选项卡);
primaryStage.SetResizeable(真);
设置场景(新场景(tabPane,600500));
}
专用选项卡生成器选项卡(字符串选项卡名称){
Tab Tab=新选项卡(tabName);
最终组根=新组();
tab.setContent(根目录);
按钮按钮=新按钮(“添加更多窗口”);
root.getChildren().addAll(按钮);
setOnAction(新的EventHandler(){
@凌驾
公共无效句柄(ActionEvent arg0){
//创建标题为“我的窗口”的窗口
窗口w=新窗口(“我的窗口”#“+计数器);
//将窗口位置设置为10,10(画布内的坐标)
w、 setLayoutX(10);
w、 setLayoutY(10);
//定义初始窗口大小
w、 setPrefSize(300200);
//要么向左
w、 getLeftIcons().add(新建CloseIcon(w));
//…还是向右
w、 getRightIcons().add(新的最小化图标(w));
//添加一些内容
w、 getContentPane().getChildren().add(新标签(“内容…\n窗口的“#”+”计数器++);
//将窗口添加到画布
root.getChildren().add(w);
}
});
返回选项卡;
}
public double getSampleWidth(){return 600;}
public double getSampleHeight(){return 500;}
@凌驾
public void start(Stage primaryStage)引发异常{
初始阶段;
primaryStage.show();
}
公共静态void main(字符串[]args){launch(args);}
}


我不知道这是否正是您想要的。希望它有帮助!

查看上的窗口控件。我还回答了一个与内部窗口相关的问题。希望它有帮助。谢谢安东尼奥,请仔细查看。@Antonio:好吧,我已经按照您的建议做了一次了
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;
import jfxtras.labs.scene.control.window.CloseIcon;
import jfxtras.labs.scene.control.window.MinimizeIcon;
import jfxtras.labs.scene.control.window.Window;


public class WindowInTab extends Application {
private static int counter = 1;

private void init(Stage primaryStage) {
    TabPane tabPane = new TabPane();
    Tab tab = generateTab("Windows...");        
    Tab anotherTab = generateTab("More Windows");
    tabPane.getTabs().addAll(tab, anotherTab);      
    primaryStage.setResizable(true);
    primaryStage.setScene(new Scene(tabPane, 600, 500));        
}

private Tab generateTab(String tabName) {
    Tab tab = new Tab(tabName);
    final Group root = new Group();
    tab.setContent(root);
    Button button = new Button("Add more windows");     

    root.getChildren().addAll(button);      

    button.setOnAction(new EventHandler<ActionEvent>() {            
        @Override
        public void handle(ActionEvent arg0) {
            // create a window with title "My Window"
            Window w = new Window("My Window#"+counter);
            // set the window position to 10,10 (coordinates inside canvas)
            w.setLayoutX(10);
            w.setLayoutY(10);
            // define the initial window size
            w.setPrefSize(300, 200);
            // either to the left
            w.getLeftIcons().add(new CloseIcon(w));
            // .. or to the right
            w.getRightIcons().add(new MinimizeIcon(w));
            // add some content
            w.getContentPane().getChildren().add(new Label("Content... \nof the window#"+counter++));
            // add the window to the canvas
            root.getChildren().add(w);  
        }
    });
    return tab;
}

public double getSampleWidth() {return 600;}
public double getSampleHeight() {return 500;}

@Override
public void start(Stage primaryStage) throws Exception {
    init(primaryStage);
    primaryStage.show();
}
public static void main(String[] args) {launch(args);}

}