diff --git a/out/production/lesson1/.idea/.gitignore b/out/production/lesson1/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/out/production/lesson1/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/out/production/lesson1/.idea/lesson1.iml b/out/production/lesson1/.idea/lesson1.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/out/production/lesson1/.idea/lesson1.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/lesson1/.idea/misc.xml b/out/production/lesson1/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/out/production/lesson1/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/lesson1/.idea/modules.xml b/out/production/lesson1/.idea/modules.xml new file mode 100644 index 0000000..bf48b8e --- /dev/null +++ b/out/production/lesson1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/lesson1/.idea/vcs.xml b/out/production/lesson1/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/out/production/lesson1/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/lesson1/Main.class b/out/production/lesson1/Main.class new file mode 100644 index 0000000..37f4f3f Binary files /dev/null and b/out/production/lesson1/Main.class differ diff --git a/out/production/lesson1/text1.class b/out/production/lesson1/text1.class new file mode 100644 index 0000000..559205f Binary files /dev/null and b/out/production/lesson1/text1.class differ diff --git a/text1.java b/text1.java new file mode 100644 index 0000000..815850e --- /dev/null +++ b/text1.java @@ -0,0 +1,52 @@ +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; + +public class text1 extends Application { + + @Override + public void start(Stage primaryStage) { + // 创建文本输入框 + TextField inputField = new TextField(); + inputField.setPromptText("输入一个十进制数"); + + // 创建标签显示结果 + Label binaryLabel = new Label(); + Label octalLabel = new Label(); + Label hexLabel = new Label(); + + // 创建按钮 + Button convertButton = new Button("转换"); + convertButton.setOnAction(e -> { + try { + int number = Integer.parseInt(inputField.getText()); + binaryLabel.setText(String.format("二进制: %s", Integer.toBinaryString(number).toUpperCase())); + octalLabel.setText(String.format("八进制: %s", Integer.toOctalString(number))); + hexLabel.setText(String.format("十六进制: %s", Integer.toHexString(number).toUpperCase())); + } catch (NumberFormatException ex) { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("输入错误"); + alert.setHeaderText("无效输入"); + alert.setContentText("请输入一个有效的十进制数。"); + alert.showAndWait(); + } + }); + + // 创建布局 + VBox vBox = new VBox(10); + vBox.getChildren().addAll(inputField, convertButton, binaryLabel, octalLabel, hexLabel); + + // 设置场景 + Scene scene = new Scene(vBox, 300, 200); + + primaryStage.setTitle("进制转换器"); + primaryStage.setScene(scene); + primaryStage.show(); + } + + public static void main(String[] args) { + launch(args); + } +} \ No newline at end of file diff --git a/进制转换.java b/进制转换.java deleted file mode 100644 index db6b3f8..0000000 --- a/进制转换.java +++ /dev/null @@ -1,2 +0,0 @@ -public class 进制转换 { -}