我需要通过点击一个按钮来显示TabPane中的一个或多个舞台,如下面的图片
我的目标是在Swing中有一个类似于JInternalFrame的情况:如何实现这一点?我无法作为子级添加到选项卡窗格中。
如果这是不可能的,还有什么其他的解决办法?我想让SplitPanes上台。
谢谢
我正在使用Win7,NetBeans 7.4Beta (Build 201307092200),SceneBuilder 1.1
编辑:这里是如何处理一些VFXWindows css更改的
有一件事值得注意:我必须添加一个节点(在我的例子中是一个带有HBox (0,0)的prefSize),否则我不能移动调整绘制的第一个窗口的大小,只有第一个窗口。
最后,我无法找到设置windows全屏(最大化)的方法。
发布于 2013-07-24 06:15:23
这里我给出了一个jfxtras窗口在Tabs中的例子,我只是修改了示例。
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);}
}
我不知道这是不是你要找的。希望能帮上忙!
https://stackoverflow.com/questions/17813498
复制