commit
c5c88d04da
@ -0,0 +1,29 @@
|
||||
### IntelliJ IDEA ###
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/test shift.iml" filepath="$PROJECT_DIR$/test shift.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,5 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class shift6247 extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
primaryStage.setTitle("进制转换器");
|
||||
|
||||
// 创建布局
|
||||
GridPane grid = new GridPane();
|
||||
grid.setPadding(new Insets(10));
|
||||
grid.setVgap(8);
|
||||
grid.setHgap(10);
|
||||
|
||||
// 输入框
|
||||
Label inputLabel = new Label("输入数值:");
|
||||
GridPane.setConstraints(inputLabel, 0, 0);
|
||||
TextField inputField = new TextField();
|
||||
GridPane.setConstraints(inputField, 1, 0);
|
||||
|
||||
// 源进制选择
|
||||
Label fromBaseLabel = new Label("源进制:");
|
||||
GridPane.setConstraints(fromBaseLabel, 0, 1);
|
||||
ComboBox<Integer> fromBaseCombo = new ComboBox<>();
|
||||
fromBaseCombo.getItems().addAll(2, 10, 16);
|
||||
fromBaseCombo.setValue(10); // 默认选择十进制
|
||||
GridPane.setConstraints(fromBaseCombo, 1, 1);
|
||||
|
||||
// 目标进制选择
|
||||
Label toBaseLabel = new Label("目标进制:");
|
||||
GridPane.setConstraints(toBaseLabel, 0, 2);
|
||||
ComboBox<Integer> toBaseCombo = new ComboBox<>();
|
||||
toBaseCombo.getItems().addAll(2, 10, 16);
|
||||
toBaseCombo.setValue(10); // 默认选择十进制
|
||||
GridPane.setConstraints(toBaseCombo, 1, 2);
|
||||
|
||||
// 转换按钮
|
||||
Button convertButton = new Button("转换");
|
||||
GridPane.setConstraints(convertButton, 1, 3);
|
||||
|
||||
// 输出框
|
||||
Label resultLabel = new Label("结果:");
|
||||
GridPane.setConstraints(resultLabel, 0, 4);
|
||||
TextField resultField = new TextField();
|
||||
resultField.setEditable(false);
|
||||
GridPane.setConstraints(resultField, 1, 4);
|
||||
|
||||
// 处理转换逻辑
|
||||
convertButton.setOnAction(e -> {
|
||||
String input = inputField.getText();
|
||||
int fromBase = fromBaseCombo.getValue();
|
||||
int toBase = toBaseCombo.getValue();
|
||||
String result = convertBase(input, fromBase, toBase);
|
||||
resultField.setText(result);
|
||||
});
|
||||
|
||||
// 添加所有控件到布局
|
||||
grid.getChildren().addAll(inputLabel, inputField, fromBaseLabel, fromBaseCombo,
|
||||
toBaseLabel, toBaseCombo, convertButton, resultLabel, resultField);
|
||||
|
||||
// 创建场景并显示
|
||||
Scene scene = new Scene(grid, 400, 200);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
private String convertBase(String value, int fromBase, int toBase) {
|
||||
try {
|
||||
// 将输入值从源进制转换为十进制
|
||||
int decimalValue = Integer.parseInt(value, fromBase);
|
||||
// 将十进制转换为目标进制
|
||||
return Integer.toString(decimalValue, toBase).toUpperCase();
|
||||
} catch (NumberFormatException e) {
|
||||
return "输入无效";
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in new issue