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);
}
}이상은 본문의 전체 내용입니다. 여러분의 학습에 도움이 되기를 바랍니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
javaFX 오목 미니 게임 실현javaFX 오목 게임 실현,참고 하 시기 바 랍 니 다.구체 적 인 내용 은 다음 과 같 습 니 다. 과정 디자인 을 할 때 이것 을 하고 공유 하면 여러분 이 참고 하 세 요.사진 은 게임 운영 과정 입 니 다....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.