-1
我需要一些幫助。你如何在HBox的文本中心?我正在使用SceneBuilder。我嘗試,我無法弄清楚如何去做。JavaFX和FXML:將文本居中在HBox中
這是FXML的代碼。
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.geometry.Point3D?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Text?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
<top>
<HBox prefHeight="50.0" prefWidth="800.0" BorderPane.alignment="CENTER">
<children>
<Text boundsType="LOGICAL_VERTICAL_CENTER" layoutX="600.0" layoutY="600.0" scaleZ="0.0" strokeType="OUTSIDE" strokeWidth="0.0" text="GIANTS DATABASE" textAlignment="CENTER" textOrigin="CENTER" wrappingWidth="231.7841796875" x="600.0" y="600.0">
<rotationAxis>
<Point3D x="1.0" y="1.0" z="1.0" />
</rotationAxis>
</Text>
</children></HBox>
</top>
<right>
<TableView prefHeight="550.0" prefWidth="577.0" BorderPane.alignment="CENTER">
<columns>
<TableColumn minWidth="0.0" prefWidth="72.0" text="Rank" />
<TableColumn editable="false" minWidth="0.0" prefWidth="206.0" text="Name" />
<TableColumn editable="false" minWidth="0.0" prefWidth="88.0" text="Position" />
<TableColumn minWidth="0.0" prefWidth="77.0" text="School" />
<TableColumn minWidth="0.0" prefWidth="66.0" text="Age" />
<TableColumn minWidth="0.0" prefWidth="66.0" text="War" />
</columns>
</TableView>
</right>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets bottom="3.0" right="3.0" />
</padding>
我想中心的文字是巨人DATABASE,在HBox中兒童
這裏是JavaFX的
代碼public class Login extends Application {
@Override
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("/giants/LoginF.fxml"));
Scene scene = new Scene(root);
primaryStage.setTitle("Giants Database Login");
primaryStage.setScene(scene);
primaryStage.show();
}
catch (Exception e) {
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
這裏的形象文字* GIANTS DATABASE。我想其中的箭頭指向文本居中**