【JAVA快速编写UI】 Java 编写一个编码转换和加解密工具,可以创建一个简单的 GUI 应用程序(例子)

03-18 1265阅读

EncodingDecodingTool/
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── com/
│   │   │       └── rockmelodies/
│   │   │           └── encodingdecodingtool/
│   │   │               ├── MainApp.java
│   │   │               ├── controller/
│   │   │               │   └── MainController.java
│   │   │               └── util/
│   │   │                   └── CryptoUtils.java
│   │   └── resources/
│   │       └── com/
│   │           └── rockmelodies/
│   │               └── encodingdecodingtool/
│   │                   └── view/
│   │                       ├── main_layout.fxml
│   │                       └── styles.css
└── pom.xml
# MainApp.java
package com.rockmelodies.encodingdecodingtool;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MainApp extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("/com/rockmelodies/encodingdecodingtool/view/main_layout.fxml"));
        primaryStage.setTitle("Encoding & Decoding Tool");
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }
    public static void main(String[] args) {
        launch(args);
    }
}
# CryptoUtils.java
package com.rockmelodies.encodingdecodingtool;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MainApp extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("/com/rockmelodies/encodingdecodingtool/view/main_layout.fxml"));
        primaryStage.setTitle("Encoding & Decoding Tool");
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }
    public static void main(String[] args) {
        launch(args);
    }
}
# MainController
package com.rockmelodies.encodingdecodingtool.controller;
import javafx.fxml.FXML;
import javafx.scene.Scene;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import com.rockmelodies.encodingdecodingtool.util.CryptoUtils;
public class MainController {
    @FXML
    private TextField inputField;
    @FXML
    private TextArea outputArea;
    @FXML
    private void handleBase64Encode() {
        String input = inputField.getText();
        String encoded = CryptoUtils.base64Encode(input);
        outputArea.setText(encoded);
    }
    @FXML
    private void handleBase64Decode() {
        String input = inputField.getText();
        String decoded = CryptoUtils.base64Decode(input);
        outputArea.setText(decoded);
    }
    public void switchTheme(String theme) {
        Scene scene = inputField.getScene();
        scene.getStylesheets().clear();
        scene.getStylesheets().add(getClass().getResource("/com/rockmelodies/encodingdecodingtool/view/" + theme + ".css").toExternalForm());
    }
    // Add more handlers for other encoding/decoding and encryption/decryption methods
}

main_layout.fxml




    
    
    
    
    

styless.css




    
    
    
    
    

【JAVA快速编写UI】 Java 编写一个编码转换和加解密工具,可以创建一个简单的 GUI 应用程序(例子)

【JAVA快速编写UI】 Java 编写一个编码转换和加解密工具,可以创建一个简单的 GUI 应用程序(例子)

VPS购买请点击我

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

目录[+]