javaFX-如何在屏幕底部放置文本区域

巴德尔

我是javafx的初学者,所以我正在使用聊天应用程序UI。我想在屏幕底部放置一个文本区域,无论屏幕大小如何,都必须保持在该位置。

这是我的FXML文件:

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

<?import com.jfoenix.controls.JFXTextArea?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>

<GridPane fx:id="gridParent" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="550.0" prefWidth="750.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.bmi.client.AccueilController">
  <columnConstraints>
    <ColumnConstraints hgrow="SOMETIMES" maxWidth="228.0" 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>
   <children>
      <AnchorPane fx:id="listePane" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: #1D232A;" />
      <AnchorPane fx:id="convPane" prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
         <children>
            <Pane fx:id="namePane" prefHeight="47.0" prefWidth="375.0" style="-fx-background-color: #b0b0b0;">
               <children>
                  <Label fx:id="nameLabel" layoutX="14.0" layoutY="15.0" />
               </children>
            </Pane>
            <JFXTextArea fx:id="messageArea" layoutY="482.0" prefHeight="68.0" prefWidth="375.0" promptText="Ecrire un message..." style="-fx-background-color: white; -fx-border-radius: 10px;"  />
         </children>
      </AnchorPane>
   </children>
</GridPane>

这是FXML File 图像的屏幕截图

当我调整屏幕大小时,会得到类似的图像:image2

塞德里克

这是使用anHBox作为根的一种方法

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

<?import com.jfoenix.controls.JFXTextArea?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>

<HBox prefHeight="550.0" prefWidth="750.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <AnchorPane fx:id="listePane" prefHeight="200.0" prefWidth="200.0" style="-fx-background-color: #1D232A;" />
      <VBox prefHeight="200.0" prefWidth="100.0" HBox.hgrow="ALWAYS">
         <children>
            <Pane fx:id="namePane" prefHeight="47.0" prefWidth="375.0" style="-fx-background-color: #b0b0b0;" VBox.vgrow="ALWAYS">
               <children>
                  <Label fx:id="nameLabel" layoutX="14.0" layoutY="15.0" />
               </children>
            </Pane>
            <JFXTextArea fx:id="messageArea" prefHeight="68.0" prefWidth="375.0" promptText="Ecrire un message..." style="-fx-background-color: white; -fx-border-radius: 10px;" />
         </children>
      </VBox>
   </children>
</HBox>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章