Commit 42f2036e authored by Håvard Østli Fjørkenstad's avatar Håvard Østli Fjørkenstad 🐞
Browse files

Moved upload/search to GUI and added preview scenes

parent 8535533c
......@@ -6,6 +6,7 @@
<change beforePath="$PROJECT_DIR$/src/main/java/GUI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/GUI.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/GUI.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/GUI.class" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
......@@ -116,6 +117,7 @@
<workItem from="1583753156713" duration="100000" />
<workItem from="1583753655631" duration="348000" />
<workItem from="1583754132295" duration="1150000" />
<workItem from="1584017476384" duration="816000" />
</task>
<task id="LOCAL−00001" summary="Commit 3, Added Comment">
<created>1583407680263</created>
......
......@@ -7,43 +7,38 @@ import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.Window;
import java.util.Optional;
public class GUI extends Application {
private static Stage primaryStage;
private static Scene scene;
private static Scene mainScene;
public static Stage getPrimaryStage(){
return primaryStage;
}
private Scene uploadScene;
private Scene searchScene;
public static Scene getScene(){
return scene;
}
@Override
public void start(Stage primaryStage) throws Exception{
// Setting up for other scenes
GUI.primaryStage = primaryStage;
Upload upload = new Upload();
Search search = new Search();
Scene uploadScene = upload.getScene();
Scene searchScene = search.getScene();
uploadScene = setUploadScene();
searchScene = setSearchScene();
// Main Scene construction
VBox root = new VBox();
HBox buttons = new HBox();
// Create Search Button
Button searchBtn = createPathButton("search_btn.png", searchScene, 40, 40);
Button searchBtn = createPathButton("","search_btn.png", searchScene, 40, 40);
// Create Uploads Button
Button uploadBtn = createPathButton("upload_btn.png", uploadScene, 40, 40);
Button uploadBtn = createPathButton("","upload_btn.png", uploadScene, 40, 40);
// Add buttons to button grid
buttons.getChildren().addAll(searchBtn,uploadBtn);
......@@ -55,25 +50,131 @@ public class GUI extends Application {
root.setAlignment(Pos.CENTER);
// Stage stuff
scene = new Scene(root, 800, 600);
mainScene = new Scene(root, 800, 600);
primaryStage.setTitle("JavaFX for Retards");
primaryStage.setScene(scene);
primaryStage.setScene(mainScene);
primaryStage.show();
}
/**
* Method for setting up the search scene
* @return
*/
private Scene setSearchScene(){
// Layout
VBox root = new VBox();
BorderPane content = new BorderPane();
root.setBackground(Background.EMPTY);
// Create Back Button
Button backBtn = new Button("Back");
backBtn.setLayoutX(50);
backBtn.setLayoutY(10);
backBtn.setOnAction(e-> primaryStage.setScene(mainScene));
Button previewBtn = new Button("Preview");
// Create some text
Label text = new Label("THIS IS THE SEARCH PAGE");
content.setCenter(text);
content.setCenter(previewBtn);
// Add nodes to root
root.getChildren().add(createMenuBar());
root.getChildren().add(backBtn);
root.getChildren().add(content);
Scene scene = new Scene(root, 800, 600, Color.TURQUOISE);
Scene previewScene = setPreviewScene(scene, false);
previewBtn.setOnAction(e -> primaryStage.setScene(previewScene));
return scene;
}
/**
* Method for setting up the upload scene
* @return
*/
private Scene setUploadScene(){
//Layout
VBox root = new VBox();
BorderPane content = new BorderPane();
root.setBackground(Background.EMPTY);
// Create Back Button
Button backBtn = new Button("Back");
backBtn.setLayoutX(50);
backBtn.setLayoutY(10);
backBtn.setOnAction(e-> primaryStage.setScene(mainScene));
Button previewBtn = new Button("Preview");
// Create some text
Label text = new Label("THIS IS THE UPLOAD PAGE");
content.setCenter(text);
content.setCenter(previewBtn);
// Add nodes to root
root.getChildren().add(createMenuBar());
root.getChildren().add(backBtn);
root.getChildren().add(content);
Scene scene = new Scene(root, 800, 600, Color.PEACHPUFF);
Scene previewScene = setPreviewScene(scene, true);
previewBtn.setOnAction(e -> primaryStage.setScene(previewScene));
return scene;
}
private Scene setPreviewScene(Scene previousScene, boolean isUpload){
VBox root = new VBox();
BorderPane content = new BorderPane();
root.setBackground(Background.EMPTY);
// Create Back Button
Button backBtn = new Button("Back");
backBtn.setLayoutX(50);
backBtn.setLayoutY(10);
backBtn.setOnAction(e-> primaryStage.setScene(previousScene));
// Create confirmation button
Button confirmBtn = new Button("Confirm Upload");
confirmBtn.setOnAction(e -> createAlert()); //Upload data to database when button is pressed
if(isUpload){ content.setBottom(confirmBtn);}
// Create some text
Label text = new Label("THIS IS THE PREVIEW PAGE");
content.setCenter(text);
// Add nodes to root
root.getChildren().add(createMenuBar());
root.getChildren().add(backBtn);
root.getChildren().add(content);
return new Scene(root, 800, 600, Color.HONEYDEW);
}
private void createAlert(){
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Lorem Ipsum");
alert.setHeaderText("Upload Successful");
Optional<ButtonType> result = alert.showAndWait();
}
/**
* Method for creating a path buttons, used to move from one scene to another.
* @param buttonName text that will be displayed on the button
* @param imagePathName name of the image that will be displayed on the button
* @param scenePath the scene that the button will direct to
* @param x width of the button
* @param y height of the button
* @param width width of the button
* @param height height of the button
* @return a working button with a height, width and image that when clicked, changes the scene to another
*/
public Button createPathButton(String imagePathName, Scene scenePath, int x, int y){
Button btn = new Button();
public Button createPathButton(String buttonName, String imagePathName, Scene scenePath, int width, int height){
Button btn = new Button(buttonName);
btn.setGraphic(new ImageView(new Image(getClass().getResourceAsStream(imagePathName))));
btn.setOnAction(e->primaryStage.setScene(scenePath));
btn.resize(x, y);
btn.setOnAction(e-> {
primaryStage.setScene(scenePath);
});
btn.resize(width, height);
return btn;
}
......
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
public class Search {
Scene scene;
public Search(){
VBox root = new VBox();
BorderPane content = new BorderPane();
root.setBackground(Background.EMPTY);
// Create Back Button
Button backBtn = new Button("Back");
backBtn.setLayoutX(50);
backBtn.setLayoutY(10);
backBtn.setOnAction(e-> GUI.getPrimaryStage().setScene(GUI.getScene()));
// Create some text
Label text = new Label("THIS IS THE SEARCH PAGE");
content.setCenter(text);
// Add nodes to root
root.getChildren().add(GUI.createMenuBar());
root.getChildren().add(backBtn);
root.getChildren().add(content);
scene = new Scene(root, 800, 600, Color.TURQUOISE);
}
public Scene getScene(){
return this.scene;
}
}
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.Background;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
public class Upload {
private Scene scene;
public Upload(){
VBox root = new VBox();
BorderPane content = new BorderPane();
root.setBackground(Background.EMPTY);
// Create Back Button
Button backBtn = new Button("Back");
backBtn.setLayoutX(50);
backBtn.setLayoutY(10);
backBtn.setOnAction(e-> GUI.getPrimaryStage().setScene(GUI.getScene()));
// Create some text
Label text = new Label("THIS IS THE UPLOAD PAGE");
content.setCenter(text);
// Add nodes to root
root.getChildren().add(GUI.createMenuBar());
root.getChildren().add(backBtn);
root.getChildren().add(content);
scene = new Scene(root, 800, 600, Color.PALEVIOLETRED);
}
public Scene getScene(){
return this.scene;
}
}
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment