자바FX MVC 모델 틀 잡기
prefHeight 높이 설정
prefWidth 너비 설정
childern 자식 으로 ListView 가 들어갈 수 있는데 하나하나 원소를 담을 수 있는 리스트를 보여주는 공간
TextArea 에서 editable 은 수정 가능 여부
Main.java
package controller;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class Main extends Application {
private Stage primaryStage;
private AnchorPane layout;
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("JavaFX ARP SPoofing");
setLayout();
}
public void setLayout() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("../view/View.fxml"));
layout = (AnchorPane) loader.load();
Scene scene = new Scene(layout);
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
public Stage getPrimaryStage() {
return primaryStage;
}
public static void main(String[] args) {
launch(args);
}
}
View.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextArea?>
<AnchorPane prefHeight="480" prefWidth="490" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ListView layoutX="15" layoutY="14" prefHeight="78" prefWidth="462"></ListView>
<Button layoutX="395" layoutY="103" prefHeight="29" prefWidth="82" text="PICK"></Button>
<TextArea editable="false" layoutX="15" layoutY="144" prefHeight="325" prefWidth="462"></TextArea>
</children>
</AnchorPane>