Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gui;
- import java.io.File;
- import java.io.IOException;
- import java.net.Inet4Address;
- import java.net.InetAddress;
- import java.net.UnknownHostException;
- import Networking.Client;
- import javafx.event.ActionEvent;
- import javafx.fxml.FXML;
- import javafx.scene.control.Button;
- import javafx.scene.control.TextField;
- import javafx.stage.Stage;
- /**
- * Created by michael on 21/09/14.
- */
- public class ExportControl {
- private File file;
- private String IP;
- private Stage dialogStage;
- String IPV4_REGEX = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$";
- @FXML
- private TextField ipTextField;
- @FXML
- private TextField fileTextField;
- @FXML
- private Button chooseFileButton;
- @FXML
- public void initialize() {
- ipTextField.setPromptText("localhost");
- }
- @FXML
- void handleChoose(ActionEvent event) {
- file = FileExplorer.requestJSON();
- if (file != null) {
- fileTextField.setPromptText(file.toString());
- }
- }
- @FXML
- void handleExport(ActionEvent event) {
- if (file != null) {
- if (ipTextField.getText() == null || ipTextField.getText().length() == 0) {
- String plzwork[];
- try {
- plzwork = InetAddress.getLocalHost().toString().split("/");
- ipTextField.setText(plzwork[1]);
- } catch (UnknownHostException e) {
- e.printStackTrace();
- }
- }
- Client client = new Client();
- try {
- client.connect(ipTextField.getText());
- client.sendFile(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- client.disconnect();
- }
- }
- @FXML
- void handleCancel(ActionEvent event) { dialogStage.close();}
- public File getFile() {
- return file;
- }
- public void setDialogStage(Stage stage) {
- this.dialogStage = stage;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement