Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Using Java language and specifically JavaFX ONLY no swing or jpanel, netbeans I

ID: 3669870 • Letter: #

Question

(Using Java language and specifically JavaFX ONLY no swing or jpanel, netbeans IDE, REPOST - so this was responded to with correct code but i didnt understand it very well can someone please do this and tell me whats going on with comments or write directly in the chat? thanks)

My Photos

create a photo album application. Your application will load a collection of images and display them in a photo album layout. The program will allow the user to tag an image with the following metadata:

- Title for the photo (limited to 20 characters)

- Description of the photo. Limited to 100 characters

- Date Taken

- Place Taken

Functional Specification

- Your album should allow sorting the pictures by Title, Date, and Place.

- When the user clicks on a photo, the metadata should be displayed

- The user should be able to add or remove photos from the album

Additional requirements

- Any test photos must be included with project source

- All photos should have maximum and minimum dimensions so that huge photos do not take up all the program’s viewing real estate and smaller photos are not so small that they’re indistinguishable.

- All paths should be relative paths or URL paths. No hard-coded file paths!

- All controls must be viewable without adjusting the parent Window

- Only javaFX GUI controls can be used. No Swing or AWT controls.

- No GUI designers may be used.

I would love this code as a reference, purhaps explain whats going on to me either with comments or seperate, because i know what im doing but only slightly i am a noobie afterall :D. thanks.

Explanation / Answer

Can help u with this:


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.TilePane;
import javafx.scene.paint.Color;
import javafx.stage.Screen;
import javafx.stage.Stage;
public class ImageGallery extends Application
{
Stage stage;
public void start(Stage primaryStage) throws Exception
{
stage = primaryStage;
ScrollPane root = new ScrollPane();
TilePane tile = new TilePane();
root.setStyle("-fx-background-color: DAE6F3;");
tile.setPadding(new Insets(15, 15, 15, 15));
tile.setHgap(15);
String path = "give your path here";
File folder = new File(path);
File[] listOfFiles = folder.listFiles();
for (final File file : listOfFiles)
{
ImageView imageView;
imageView = createImageView(file);
tile.getChildren().addAll(imageView);
}
root.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
root.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
root.setFitToWidth(true);
root.setContent(tile);
primaryStage.setWidth(Screen.getPrimary().getVisualBounds().getWidth());
primaryStage.setHeight(Screen.getPrimary().getVisualBounds()
.getHeight());
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
private ImageView createImageView(final File imageFile)
{
ImageView imageView = null;
try
{
final Image image = new Image(new FileInputStream(imageFile), 150, 0, true,true);
imageView = new ImageView(image);
imageView.setFitWidth(150);
imageView.setOnMouseClicked(new EventHandler<MouseEvent>()
{
public void handle(MouseEvent mouseEvent)
{
if(mouseEvent.getButton().equals(MouseButton.PRIMARY))
{
if(mouseEvent.getClickCount() == 2)
{
try
{
BorderPane borderPane = new BorderPane();
ImageView imageView = new ImageView();
Image image = new Image(new FileInputStream(imageFile));
imageView.setImage(image);
imageView.setStyle("-fx-background-color: BLACK");
imageView.setFitHeight(stage.getHeight() - 10);
imageView.setPreserveRatio(true);
imageView.setSmooth(true);
imageView.setCache(true);
borderPane.setCenter(imageView);
borderPane.setStyle("-fx-background-color: BLACK");
Stage newStage = new Stage();
newStage.setWidth(stage.getWidth());
newStage.setHeight(stage.getHeight());
newStage.setTitle(imageFile.getName());
Scene scene = new Scene(borderPane,Color.BLACK);
newStage.setScene(scene);
newStage.show();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
}
}
});
}
catch (FileNotFoundException ex)
{
ex.printStackTrace();
}
return imageView;
}
public static void main(String[] args)
{
launch(args);
}
}