JavaFX 8 Tutorial 48 - ImageView
The code written in this tutorial is :
private ImageView imageView;
private Image image;
browse.setOnAction(e ->{
//Single File Selection
file = fileChooser.showOpenDialog(primaryStage);
if(file != null){
textArea.setText(file.getAbsolutePath());
image = new Image(file.toURI().toString(), 100, 150, true, true);//path, PrefWidth, PrefHeight, PreserveRatio, Smooth
imageView = new ImageView(image);
imageView.setFitWidth(100);
imageView.setFitHeight(150);
imageView.setPreserveRatio(true);
layout.setCenter(imageView);
BorderPane.setAlignment(imageView, Pos.TOP_LEFT);
}
//Multiple File Selection
/*List<File> fileList = fileChooser.showOpenMultipleDialog(primaryStage);
if(fileList != null){
fileList.stream().forEach(selectedFiles ->{
textArea.setText(fileList.toString());
});
}*/
});
fields.getChildren().addAll(searchField, label1, id, fn, ln, em, mobile, un, pw, date, male, female, checkBox1, checkBox2, checkBox3, browse, textArea, button);
layout.setLeft(fields);
BorderPane.setMargin(fields, new Insets(0, 10, 0, 10));
//layout.setLeft(list);
//BorderPane.setMargin(list, new Insets(10));
Comments
Post a Comment