简体   繁体   English

如何更改JavaFX TabPane窗格类型

[英]How to change JavaFX TabPane pane type

I want to make a WebView inside an AnchorPane controlled by the TabPane: 我想在由TabPane控制的AnchorPane中制作一个WebView: 图片

Here's the TabPane hierarchy in this: 这是其中的TabPane层次结构:

在此处输入图片说明

I don't know how to make a WebView fill the entire area, and be responsive at the same time. 我不知道如何使WebView充满整个区域,并同时做出响应。 I can change the preferred size, but I don't know how to make it 100% fill the pane. 我可以更改首选大小,但是我不知道如何使其100%填充窗格。 I'm brand new to JavaFX, and I am using the Scene Builder (I came from Swing). 我是JavaFX的新手,并且正在使用Scene Builder(我来自Swing)。 Thank you! 谢谢!

A tab will size its content node to fill all the available space in the tab (up to its max size). 选项卡将调整其内容节点的大小,以填充选项卡中的所有可用空间(最大为其最大大小)。 So as long as you leave the max width and max height of a web view as their defaults ( Double.MAX_VALUE ), you can simply place the web view directly in the tab without using an anchor pane, and it will be sized to the full size of the tab. 因此,只要将网络视图的最大宽度和最大高度保留为默认值( Double.MAX_VALUE ),就可以直接将网络视图直接放置在选项卡中,而无需使用锚定窗格,并且它的大小将为完整标签的大小。

Here is a simple example: 这是一个简单的示例:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.web.*?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.TabPane?>


<TabPane xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
   <tabs>
      <Tab text="Untitled Tab">
         <content>
            <WebView fx:id="webView" prefHeight="200.0" prefWidth="200.0" />
         </content>
      </Tab>
   </tabs>
</TabPane>

Here is the document hierarchy in Scene Builder: 这是Scene Builder中的文档层次结构:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM