idea的FXMLLoader

博客介绍了使用IntelliJ IDEA创建JavaFX项目的步骤。首先打开idea,通过File - New - Project - Java FX - next完成项目新建。之后可在.fxml布局里编写代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先来个效果图.

下面教大家如果写.

1.打开idea,新建项目File ---  New -- Project --- Java FX  -- next就好了.

然后finish结束.新建项目结束.

2.在 .fxml 布局里写代码.如下:

<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.text.Text?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.collections.FXCollections?>
<?import java.lang.String?>
<GridPane fx:controller="sample.Controller"
          xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">

    <Label text="姓名" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
    <Label text="性别" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
    <ChoiceBox fx:id="cb_select_sex" GridPane.columnIndex="1" GridPane.rowIndex="1" prefWidth="200.0">
        <items>
            <FXCollections fx:factory="observableArrayList">
                <String fx:value="男"/>
                <String fx:value="女"/>
            </FXCollections>
        </items>
    </ChoiceBox>

    <Label text="年龄" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
    <Label text="家庭住址" GridPane.columnIndex="0" GridPane.rowIndex="3"/>

    <CheckBox text="男" GridPane.columnIndex="0" GridPane.rowIndex="4"/>
    <CheckBox text="女" GridPane.columnIndex="1" GridPane.rowIndex="4"/>

    <RadioButton text="男" GridPane.columnIndex="0" GridPane.rowIndex="5"/>
    <RadioButton text="女" GridPane.columnIndex="1" GridPane.rowIndex="5"/>

    <Button fx:id="click" text="点击" GridPane.columnIndex="0" GridPane.rowIndex="6"/>
    <Label text="密码" GridPane.columnIndex="0" GridPane.rowIndex="7"/>


    <TextField GridPane.columnIndex="1" GridPane.rowIndex="0"/>
    <TextField GridPane.columnIndex="1" GridPane.rowIndex="2"/>
    <TextField GridPane.columnIndex="1" GridPane.rowIndex="3"/>
    <PasswordField GridPane.columnIndex="1" GridPane.rowIndex="7"/>

    <Text text="正确" GridPane.columnIndex="2" GridPane.rowIndex="7"></Text>

</GridPane>3.讲一下  TextField---输入框     CheckBox---复选框      ChoiceBox---下拉选择框      Button---按钮    PasswordField---密码框
4.然后就over了,记得关注我哦
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值