JAVA - JavaFX - 处理调用另一个阶段的节点例如:JButton

如何解决JAVA - JavaFX - 处理调用另一个阶段的节点例如:JButton

我想要一个主舞台(主 GUI),它在顶部包含一个菜单栏,然后​​由一个带有垂直 SplitPane 的 AnchorPane 组成[拆分发生在 350 像素](右侧包含另一个水平 SplitPane ,总共给我 3 个部分来使用),或者只使用 BorderPane 的 Left、Top 和 Center 的 BorderPane。在垂直 SplitPane(或 Left BorderPane)中,我想要 3 个按钮,它们占用大约 320x320 像素,留下一个 15 像素的缓冲区。 Top 部分[200 像素高度xMaxValue 宽度] 将有一个背景图像、一个ImageView 和一个标签。现在,BorderPane 的中心部分,或第一个 SplitPane 的右侧,其中包含一个水平 SplitPane,即参考该 SplitPane 的底部,将是最大的区域。我想在那个区域有 5 个按钮,[我可以调整这些按钮的大小和间距,可能在水平 Splitpane 的底部使用一个 GridPane],当单击左侧的第一个按钮时,它将变得可见。然后我想在单击第二个按钮时显示另外 5 个不同的按钮,删除前 5 个按钮。我不知道我是否需要让左侧的按钮调用 GridPane 5 个按钮可见,或者如何设置它。然后我希望 GridPane 中的按钮调用另一个 Stage(实际上是 5 个单独的阶段,但一次一个可见),它在打开时覆盖整个第一个阶段。此外,我需要将此大小设置为打开最大化的默认大小 1440x900(最小大小)。 (我可以处理这个功能,我只需要子节点用它来调整大小,但只有一个大小。我需要第一个拆分窗格的左侧只调整高度,而顶部只调整宽度。我知道,这很多,但我尽量提供尽可能多的信息。感谢大家对此的帮助。

这是迄今为止的代码:

javaFX

package scindbmain;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

public class MainGUI extends Application {


    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent rootPane = FXMLLoader.load(getClass().getResource("maingui.fxml"));
        Scene scene = new Scene(rootPane);
        primaryStage.setTitle("Star Citizen InfoNet & Database");
        primaryStage.setScene(scene);
        primaryStage.setMinWidth(1440);
        primaryStage.setMinHeight(900);
        primaryStage.setMaximized(true);
        primaryStage.setResizable(false);
        primaryStage.show();
    }

    public static void main(String[] args){
        launch(args);

     }
}

And here is my FXML file to go with it:

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

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="1440.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <MenuBar maxHeight="25.0" minHeight="25.0" prefHeight="25.0" style="-fx-background-color: beige;" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
        <menus>
          <Menu mnemonicParsing="false" text="File">
            <items>
              <MenuItem mnemonicParsing="false" text="Close" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Edit">
            <items>
              <MenuItem mnemonicParsing="false" text="Delete" />
            </items>
          </Menu>
          <Menu mnemonicParsing="false" text="Help">
            <items>
              <MenuItem mnemonicParsing="false" text="About" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
      <SplitPane dividerPositions="0.18567454798331015" layoutY="29.0" prefHeight="900.0" prefWidth="1440.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="25.0">
        <items>
            <VBox maxWidth="350.0" minHeight="-Infinity" minWidth="350.0" prefHeight="875.0" prefWidth="350.0" spacing="30.0" style="-fx-background-color: grey;">
               <children>
                  <Button maxHeight="300.0" maxWidth="300.0" minHeight="300.0" minWidth="300.0" mnemonicParsing="false" prefHeight="300.0" prefWidth="300.0" style="-fx-background-color: silver;" text="Star Systems &amp; Locations" textAlignment="CENTER" wrapText="true">
                     <font>
                        <Font name="Impact" size="45.0" />
                     </font>
                     <VBox.margin>
                        <Insets />
                     </VBox.margin>
                  </Button>
                  <Button layoutX="25.0" layoutY="25.0" maxHeight="300.0" maxWidth="300.0" minHeight="300.0" minWidth="300.0" mnemonicParsing="false" prefHeight="300.0" prefWidth="300.0" style="-fx-background-color: silver;" text="Starships,Weapons &amp; Components" textAlignment="CENTER" wrapText="true">
                     <font>
                        <Font name="Impact" size="45.0" />
                     </font>
                     <VBox.margin>
                        <Insets />
                     </VBox.margin>
                  </Button>
                  <Button layoutX="25.0" layoutY="375.0" maxHeight="300.0" maxWidth="300.0" minHeight="300.0" minWidth="300.0" mnemonicParsing="false" prefHeight="300.0" prefWidth="300.0" style="-fx-background-color: silver;" text="Trading,Mining &amp; Refining" textAlignment="CENTER" wrapText="true">
                     <font>
                        <Font name="Impact" size="45.0" />
                     </font>
                     <VBox.margin>
                        <Insets />
                     </VBox.margin>
                  </Button>
               </children>
               <padding>
                  <Insets bottom="15.0" left="25.0" right="15.0" top="15.0" />
               </padding>
            </VBox>
            <SplitPane dividerPositions="0.22451317296678122" orientation="VERTICAL" prefHeight="200.0" prefWidth="160.0">
              <items>
                  <HBox maxHeight="200.0" minHeight="200.0" minWidth="1090.0" prefHeight="200.0" prefWidth="1090.0" spacing="25.0" style="-fx-background-color: black;">
                     <padding>
                        <Insets bottom="10.0" left="15.0" top="10.0" />
                     </padding>
                     <children>
                        <ImageView fitHeight="180.0" fitWidth="180.0" pickOnBounds="true" HBox.hgrow="NEVER">
                           <image>
                              <Image url="@../SCImages/TaktikalLogo1.jpg" />
                           </image>
                        </ImageView>
                        <Label minWidth="1000.0" prefHeight="180.0" prefWidth="1000.0" style="-fx-border-color: white;" text="STAR CITIZEN INFONET &amp; DATABASE" textAlignment="CENTER" textFill="WHITE" wrapText="true">
                           <HBox.margin>
                              <Insets bottom="10.0" top="10.0" />
                           </HBox.margin>
                           <font>
                              <Font name="Mongolian Baiti" size="68.0" />
                           </font>
                        </Label>
                     </children>
                  </HBox>
                <AnchorPane minHeight="668.0" minWidth="1090.0" prefHeight="338.0" prefWidth="1090.0">
                     <children>
                        <StackPane prefHeight="668.0" prefWidth="1090.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                           <children>
                              <GridPane>
                                <columnConstraints>
                                    <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                                  <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                                  <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
                                </columnConstraints>
                                <rowConstraints>
                                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
                                </rowConstraints>
                              </GridPane>
                           </children>
                        </StackPane>
                     </children></AnchorPane>
              </items>
            </SplitPane>
        </items>
      </SplitPane>
   </children>
</AnchorPane>
Now,as you can see I have coded some of the GUI. And I have 3 buttons on the left side. I want to have each of those buttons call a Pane(AnchorPane,StackPane,i dont know which one) to fill the bottom right of my Stage (bottom half of the horizontal StackPane) with 5 buttons on each pane. Each button will call a different Pane with 5 different buttons that will each call a different stage. But for now,I have problems with the GUI. I have it set to Maximum because if i set it to 1440x900,and set it to not resize,it will still let me resize it down a little bit,and it moves the GUI out of place. I don't think this code is the correct code to do this with,which is why I was asking for someone's example earlier,instead of putting this code up. Thank you for any help.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-