国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Java > 正文

基于socket和javaFX簡單文件傳輸工具

2019-11-26 14:36:06
字體:
來源:轉載
供稿:網友

本文實例介紹了基于socket和javaFX簡單文件傳輸工具,分享給大家供大家參考,具體內容如下

package application;   import java.io.File; import org.james.component.ButtonBox;import org.james.component.FileReceiverGrid;import org.james.component.FileSenderGrid;import javafx.application.Application;import javafx.event.ActionEvent;import javafx.event.EventHandler;import javafx.scene.Scene;import javafx.scene.layout.BorderPane;import javafx.stage.FileChooser;import javafx.stage.Stage;  public class Main extends Application {     public static Stage primaryStage;     @Override  public void start(Stage primaryStage) {    try {      this.primaryStage = primaryStage;      primaryStage.setFullScreen(false);      primaryStage.setResizable(false);             FileReceiverGrid fileReceiverGrid = new FileReceiverGrid();      fileReceiverGrid.initialize();      FileSenderGrid fileSenderGrid = new FileSenderGrid();      fileSenderGrid.initialize();             ButtonBox buttonBox = new ButtonBox();      buttonBox.initialize();             BorderPane root = new BorderPane();      root.setTop(fileReceiverGrid);      root.setBottom(buttonBox);             buttonBox.getReceiveFileFunc().setOnAction(new EventHandler<ActionEvent>() {        @Override        public void handle(ActionEvent event) {          buttonBox.getReceiveFileFunc().setDisable(true);          buttonBox.getSendFileFunc().setDisable(false);          root.setTop(fileReceiverGrid);        }      });             buttonBox.getSendFileFunc().setOnAction(new EventHandler<ActionEvent>() {        @Override        public void handle(ActionEvent event) {          buttonBox.getReceiveFileFunc().setDisable(false);          buttonBox.getSendFileFunc().setDisable(true);          root.setTop(fileSenderGrid);        }       });             fileSenderGrid.getSelectFileBtn().setOnAction(new EventHandler<ActionEvent>() {        @Override        public void handle(ActionEvent event) {          FileChooser fileChooser = new FileChooser();          fileChooser.setTitle("打開文件");          File selectedFile = fileChooser.showOpenDialog(primaryStage);          if(selectedFile != null){            fileSenderGrid.setFile(selectedFile);            fileSenderGrid.getFileNameLabel().setText(selectedFile.getPath());          }        }       });             Scene scene = new Scene(root,800,400);      scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());      primaryStage.setScene(scene);      primaryStage.show();    } catch(Exception e) {      e.printStackTrace();    }  }        public static void main(String[] args) {    launch(args);  }}

以上就是本文的全部內容,希望對大家的學習有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 怀安县| 县级市| 无极县| 河北省| 鹰潭市| 白银市| 南溪县| 德阳市| 克东县| 泰兴市| 河池市| 怀化市| 焦作市| 霞浦县| 来安县| 阜阳市| 德格县| 藁城市| 阳朔县| 乳源| 胶南市| 额尔古纳市| 葫芦岛市| 枣强县| 承德县| 霍州市| 昭觉县| 南漳县| 蓝田县| 南木林县| 伊金霍洛旗| 大冶市| 香河县| 隆子县| 巧家县| 邛崃市| 佳木斯市| 济阳县| 屯昌县| 屯昌县| 蓬溪县|