首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >JavaFx 2.x : TabPane中的阶段

JavaFx 2.x : TabPane中的阶段
EN

Stack Overflow用户
提问于 2013-07-23 14:44:46
回答 1查看 4.5K关注 0票数 0

我需要通过点击一个按钮来显示TabPane中的一个或多个舞台,如下面的图片

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

如果这是不可能的,还有什么其他的解决办法?我想让SplitPanes上台。

谢谢

我正在使用Win7,NetBeans 7.4Beta (Build 201307092200),SceneBuilder 1.1

编辑:这里是如何处理一些VFXWindows css更改的

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-24 14:15:23

这里我给出了一个jfxtras窗口在Tabs中的例子,我只是修改了示例

代码语言:javascript
代码运行次数:0
运行
复制
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);}

}

我不知道这是不是你要找的。希望能帮上忙!

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17813498

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档