JavaFX 编程语言开发互联网应用程序(RIA)

执行入口:
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
// 加载xml文件进行
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("配置中心");
primaryStage.setScene(new Scene(root, 860, 605));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
View层 FXML文件:
//绑定Controller,完整的包路径
fx:controller="sample.SampleController">
// fx:绑定Controller的属性
// 按钮绑定对应Controller对应的事件,
控制层:
import java.net.URL;
import java.time.LocalDate;
import java.util.Map;
import java.util.ResourceBundle;
public class SampleController implements Initializable {
private String securityUrl="/third/app/security/syn";
// 空间的元素ID
@FXML
private ComboBox prototypeId;
@FXML
private TextField hostName;
@FXML
private TextField hostPort;
@FXML
private TextArea privateKeyId;
@FXML
private TextArea publicKeyId;
@FXML
private TextField securityKey;
@FXML
private DatePicker startTime;
@FXML
private DatePicker endTime;
//事件方法
@FXML
private void genRsaEvent(ActionEvent event){
Map securityMap = StorgeUtils.getKeyInfo();
String privateKeyContent = securityMap.get("private");
String publicKeyContent = securityMap.get("public");
privateKeyId.setText(privateKeyContent);
publicKeyId.setText(publicKeyContent);
}
@FXML
private void handleButtonAction(javafx.event.ActionEvent event) {
StringBuilder httpReqUrl = new StringBuilder();
httpReqUrl.append(prototypeId.getValue()).append("://").append(hostName.getText()).append(":").append(hostPort.getText());
httpReqUrl.append(securityUrl);
System.out.println(httpReqUrl.toString());
System.out.println(securityKey.getText());
System.out.println(privateKeyId.getText());
System.out.println(publicKeyId.getText());
System.out.println(startTime.getValue());
System.out.println(endTime.getValue());
new AlertBox().display("信息提醒", "保存成功!");
}
@Override
public void initialize(URL location, ResourceBundle resources) {
}
475

被折叠的 条评论
为什么被折叠?



