GUI( JavaFX Scene Builder )/Layout
ImageView
by pms93
2022. 8. 16.
package application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class StackPanes2 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Label label = new Label("이미지");
label.setFont(new Font(40));
BorderPane bp = new BorderPane();
bp.setBottom(label);
// ImageView
// - 생성자를 통해 경로를 전달하여 이미지를 불러올 수 있다.
// - 경로 전달시에 상대경로로 전달한다.
ImageView iv = new ImageView("/img/images.jpg");
StackPane stack = new StackPane();
stack.getChildren().addAll(iv, bp);
primaryStage.setScene(new Scene(stack, 300, 300));
primaryStage.show();
}
}