I need to display one or more stage(s) within a TabPane by clicking on a button, such as the picture below

enter image description here

My target is to have a situation similar to JInternalFrame in Swing: how to accomplish this? I am not able to add stage as children to the tab pane.

If this is not possible, what could be other solutions? I would like to have SplitPanes on the stage.

Thanks

PS I am using Win7, NetBeans 7.4 Beta (Build 201307092200), SceneBuilder 1.1

Edit: here is how it looks after some VFXWindows css changes

enter image description here

There's one thing worth notice: I have had to add a node ( in my case an HBox with prefSize(0,0), otherwise I can't move o resize the first window plotted, only the first one.

As last, I can't find a way to set windows full screen (maximize).

有帮助吗?

解决方案

Here I put an example of windows from jfxtras inside of Tabs, I just modify the example.

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);}

}

internal windows in tabs

I don't know if this was exactly what you were looking for. Hope it helps!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top