使用JavaFX编写桌面程序,UI部分

串口程序UI,FXML文件

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

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane fx:id="anchorage" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="460.0" prefWidth="680.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.SerialAssistant">
    <children>
        <TextArea fx:id="receiveText" layoutX="11.0" layoutY="14.0" prefHeight="285.0" prefWidth="659.0" promptText="什么消息都没收到。。。" />
        <TextArea fx:id="sendText" layoutX="11.0" layoutY="309.0" prefHeight="65.0" prefWidth="426.0" promptText="发点什么好呢?" />
        <Button fx:id="sendBnt" layoutX="445.0" layoutY="387.0" mnemonicParsing="false" onAction="#onActionSendBtn" prefHeight="26.0" prefWidth="221.0" text="发送数据" />
        <Button fx:id="openBnt" layoutX="446.0" layoutY="348.0" mnemonicParsing="false" onAction="#onActionOpenBtn" prefHeight="26.0" prefWidth="221.0" text="打开串口" />
        <Button fx:id="clearBnt" layoutX="446.0" layoutY="424.0" mnemonicParsing="false" onAction="#onActionClearBtn" prefHeight="26.0" prefWidth="221.0" text="清除接收" />
        <ComboBox fx:id="comPort" layoutX="446.0" layoutY="309.0" onShown="#onShowComPort" prefHeight="26.0" prefWidth="110.0" promptText="端口" />
        <ComboBox fx:id="bandRete" layoutX="560.0" layoutY="309.0" onShown="#onShowBandRete" prefHeight="26.0" prefWidth="110.0" promptText="波特率" />
      <Button fx:id="red_on" layoutX="11.0" layoutY="387.0" mnemonicParsing="false" onAction="#onActionRed_onBtn" prefHeight="26.0" prefWidth="51.0" text="红灯" textFill="RED" />
      <Button fx:id="green_on" layoutX="85.0" layoutY="387.0" mnemonicParsing="false" onAction="#onActionGreen_onBtn" prefHeight="26.0" prefWidth="51.0" text="绿灯" textFill="#00bc16" />
      <Button fx:id="blue_on" layoutX="160.0" layoutY="387.0" mnemonicParsing="false" onAction="#onActionBlue_onBtn" prefHeight="26.0" prefWidth="51.0" text="蓝灯" textFill="#1d00fc" />
      <Button fx:id="openBnt13" layoutX="235.0" layoutY="387.0" mnemonicParsing="false" onAction="#onActionYellow_onBtn" prefHeight="26.0" prefWidth="51.0" text="黄灯" textFill="#a8b400" />
      <Button fx:id="openBnt131" layoutX="314.0" layoutY="387.0" mnemonicParsing="false" onAction="#onActionCyan_onBtn" prefHeight="26.0" prefWidth="51.0" text="青灯" textFill="#04bcbc" />
      <Button fx:id="openBnt1311" layoutX="385.0" layoutY="387.0" mnemonicParsing="false" onAction="#onActionPurple_onBtn" prefHeight="26.0" prefWidth="51.0" text="紫灯" textFill="#d10bc1" />
      <Button fx:id="openBnt14" layoutX="11.0" layoutY="424.0" mnemonicParsing="false" onAction="#onActionRed_offBtn" prefHeight="26.0" prefWidth="51.0" text="红灭" />
      <Button fx:id="openBnt111" layoutX="85.0" layoutY="424.0" mnemonicParsing="false" onAction="#onActionGreen_offBtn" prefHeight="26.0" prefWidth="51.0" text="绿灭" />
      <Button fx:id="openBnt1111" layoutX="160.0" layoutY="424.0" mnemonicParsing="false" onAction="#onActionBlue_offBtn" prefHeight="26.0" prefWidth="51.0" text="蓝灭" />
      <Button fx:id="openBnt13111" layoutX="385.0" layoutY="424.0" mnemonicParsing="false" onAction="#onActionWhite_onBtn" prefHeight="26.0" prefWidth="51.0" text="白灯" textFill="WHITE" />
      <Button fx:id="openBnt13112" layoutX="235.0" layoutY="424.0" mnemonicParsing="false" onAction="#onActionAll_offBtn" prefHeight="26.0" prefWidth="51.0" text="全灭" />
    </children>
</AnchorPane>

效果截图如下:
使用JavaFX编写桌面程序,UI部分_第1张图片

你可能感兴趣的:(java)