Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help revising errors in JavaFX code: ant -f A:UsersMattgamesNetBeansProjectsProject_7_main -Djavac.includes=project_7_main/Project_7_main.java -Dnb.internal.action.name=run.single -Drun.class=project_7_main.Project_7_main run-single init: Deleting: A:UsersMattgamesNetBeansProjectsProject_7_mainbuildbuilt-jar.properties deps-jar: Updating property file: A:UsersMattgamesNetBeansProjectsProject_7_mainbuildbuilt-jar.properties Compiling 1 source

Need help revising errors in JavaFX code:

ant -f A:\\Users\\Matt\\games\\NetBeansProjects\\Project_7_main -Djavac.includes=project_7_main/Project_7_main.java -Dnb.internal.action.name=run.single -Drun.class=project_7_main.Project_7_main run-single init: Deleting: A:\Users\Matt\games\NetBeansProjects\Project_7_main\build\built-jar.properties deps-jar: Updating property file: A:\Users\Matt\games\NetBeansProjects\Project_7_main\build\built-jar.properties Compiling 1 source file to A:\Users\Matt\games\NetBeansProjects\Project_7_main\build\classes A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:85: error: cannot find symbol pane.getChildren().clear(); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:86: error: cannot find symbol pane.getChildren().addAll(leftColumn, enterBox); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:96: error: cannot find symbol pane.getChildren().clear(); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:97: error: cannot find symbol pane.getChildren().addAll(leftColumn, findBox); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:104: error: cannot find symbol pane.getChildren().clear(); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:105: error: cannot find symbol pane.getChildren().addAll(leftColumn, deleteBox); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:112: error: cannot find symbol pane.getChildren().clear(); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:113: error: cannot find symbol pane.getChildren().addAll(leftColumn, listBox); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:120: error: cannot find symbol pane.getChildren().clear(); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:121: error: cannot find symbol pane.getChildren().addAll(leftColumn, saveBox); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:192: error: cannot find symbol entryList[num_entries] = new Entry(); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:192: error: cannot find symbol entryList[num_entries] = new Entry(); symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:193: error: cannot find symbol entryList[num_entries].name = name.getText(); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:193: error: cannot find symbol entryList[num_entries].name = name.getText(); symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:194: error: cannot find symbol entryList[num_entries].quantity = quantity.getText(); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:194: error: cannot find symbol entryList[num_entries].quantity = quantity.getText(); symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:195: error: cannot find symbol entryList[num_entries].note = notes.getText(); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:195: error: cannot find symbol entryList[num_entries].note = notes.getText(); symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:197: error: cannot find symbol System.out.println(entryList[num_entries].name + entryList[num_entries].quantity + entryList[num_entries].note); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:197: error: cannot find symbol System.out.println(entryList[num_entries].name + entryList[num_entries].quantity + entryList[num_entries].note); symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:197: error: cannot find symbol System.out.println(entryList[num_entries].name + entryList[num_entries].quantity + entryList[num_entries].note); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:197: error: cannot find symbol System.out.println(entryList[num_entries].name + entryList[num_entries].quantity + entryList[num_entries].note); symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:197: error: cannot find symbol System.out.println(entryList[num_entries].name + entryList[num_entries].quantity + entryList[num_entries].note); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:197: error: cannot find symbol System.out.println(entryList[num_entries].name + entryList[num_entries].quantity + entryList[num_entries].note); symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:199: error: cannot find symbol num_entries++; symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:203: error: cannot find symbol pane.getChildren().add(enterPane()); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:209: error: cannot find symbol pane.getChildren().remove(vBoxE); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:257: error: cannot find symbol Project_7_Main.find(findItem.getText()); symbol: variable Project_7_Main location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:274: error: cannot find symbol for (int i = 0; i < num_entries; i++) { symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:275: error: cannot find symbol if (editItem.toLowerCase().contains(entryList[i].name.toLowerCase()) || entryList[i].name.toLowerCase().contains(editItem.toLowerCase())) { symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:275: error: cannot find symbol if (editItem.toLowerCase().contains(entryList[i].name.toLowerCase()) || entryList[i].name.toLowerCase().contains(editItem.toLowerCase())) { symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:276: error: cannot find symbol pane.getChildren().remove(vBoxF); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:277: error: cannot find symbol pane.getChildren().add(editPane()); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:285: error: cannot find symbol pane.getChildren().remove(vBoxF); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:308: error: cannot find symbol for (int i = 0; i < num_entries; i++) { symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:309: error: cannot find symbol if(findName.getText().toLowerCase().contains(entryList[i].name.toLowerCase())) symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:310: error: cannot find symbol quantity.setText(entryList[i].quantity); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:320: error: cannot find symbol for (int i = 0; i < num_entries; i++) { symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:321: error: cannot find symbol if(findName.getText().toLowerCase().contains(entryList[i].name.toLowerCase())) symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:322: error: cannot find symbol notes.setText(entryList[i].note); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:343: error: cannot find symbol for (int i = 0; i < num_entries; i++) { symbol: variable num_entries location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:344: error: cannot find symbol if(findName.getText().toLowerCase().contains(entryList[i].name.toLowerCase())) { symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:345: error: cannot find symbol entryList[i].quantity = quantity.getText(); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:346: error: cannot find symbol entryList[i].note = notes.getText(); symbol: variable entryList location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:350: error: cannot find symbol CopyInventoryToFile("inventory.txt"); symbol: method CopyInventoryToFile(String) location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:361: error: cannot find symbol pane.getChildren().remove(vBoxEt); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:390: error: cannot find symbol find(""); symbol: method find(String) location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:405: error: cannot find symbol Project_7_Main.sortList(); symbol: variable Project_7_Main location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:407: error: cannot find symbol pane.getChildren().remove(vBoxL); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:408: error: cannot find symbol pane.getChildren().add(listPane()); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:418: error: cannot find symbol pane.getChildren().remove(vBoxL); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:419: error: cannot find symbol pane.getChildren().add(editPane()); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:425: error: cannot find symbol pane.getChildren().remove(vBoxL); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:476: error: cannot find symbol Project_7_Main.find(delete.getText()); symbol: variable Project_7_Main location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:486: error: cannot find symbol Project_7_Main.delete(delete.getText()); symbol: variable Project_7_Main location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:493: error: cannot find symbol pane.getChildren().remove(vBoxD); symbol: variable pane location: class VisualInterface A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java:525: error: cannot find symbol pane.getChildren().remove(vBoxS); symbol: variable pane location: class VisualInterface Note: A:\Users\Matt\games\NetBeansProjects\Project_7_main\src\project_7_main\VisualInterface.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 57 errors A:\Users\Matt\games\NetBeansProjects\Project_7_main bproject\build-impl.xml:954: The following error occurred while executing this line: A:\Users\Matt\games\NetBeansProjects\Project_7_main bproject\build-impl.xml:271: Compile failed; see the compiler error output for details. BUILD FAILED (total time: 0 seconds)

Code:

package project_7_main;

import java.io.*; import java.util.*; import javafx.application.Application; import javafx.stage.Stage;

import javafx.event.ActionEvent; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Dialog; import javafx.scene.control.TextInputDialog; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import javafx.stage.WindowEvent; import javafx.util.Pair;

class Entry {

public String name, quantity, note; }

public class Project_7_main extends Application {

public static Entry[] entryList = new Entry[200]; public static int num_entries = 0; public static Scanner stdin = new Scanner(System.in); public static BorderPane pane = new BorderPane(); public static boolean debug = true;

@Override public void start(Stage primaryStage) { Scene scene = new Scene(pane, 800, 600); primaryStage.setTitle("Inventory Managment"); pane.setStyle("-fx-background-color: #85CD66;" + "-fx-border-width: 5;" + "-fx-insets: 10;" + "-fx-border-radius: 5;" + "-fx-border-color: green;"); //Place nodes here pane.setLeft(VisualInterface.getVBox());

//Create a scene and place it in stage primaryStage.setScene(scene); //placing scene in stage primaryStage.show(); primaryStage.setOnCloseRequest((WindowEvent w) -> { try { CopyInventoryToFile("inventory.txt"); } catch (Exception e){ Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setContentText("There was a problem saving your changes!"); } });

}

public static void main(String args[]) throws Exception { readInventory("inventory.txt"); launch(args); }

public static void readInventory(String FileName) throws Exception { File F; F = new File(FileName); Scanner S = new Scanner(F);

while (S.hasNextLine()) { entryList[num_entries] = new Entry(); entryList[num_entries].name = S.next(); entryList[num_entries].quantity = S.next(); entryList[num_entries].note = S.nextLine(); num_entries++; } S.close(); }

public static void enterName(String item) { String itemName = "Item"; itemName = item; }

public static void enterQuantity(String number) { String quantity = "Quantity"; quantity = number; }

public static void enterNotes(String notes) { String itemNotes = "Notes"; itemNotes = notes; }

public static int index(String Key) { // Function to get the index of a key from an array // if not found, returns -1 for (int i = 0; i < num_entries; i++) { if (entryList[i].name.equalsIgnoreCase(Key)) { return i; // Found the Key, return index. } } return -1; }

public static void displayEntry(Entry item) { System.out.println("--" + item.name + " " + "--" + item.quantity + " " + "--" + item.note); }

public static void listAllItems() { int i = 0; while (i < num_entries) { displayEntry(entryList[i]); i++; } }

public static void find(String search) { for (int i = 0, found = 0; i < num_entries; i++){ if(search.toLowerCase().contains(entryList[i].name) || entryList[i].name.toLowerCase().contains(search)) { VisualInterface.results.add(entryList[i].name); found++; } } } public static void delete(String name){ for(int i = 0; i < num_entries; i++) { if(entryList[i].name.equals(VisualInterface.editItem)) { for(int j = i; j < num_entries; j++){ entryList[j] = entryList[j + 1]; } num_entries--; VisualInterface.results.remove(VisualInterface.editItem); } } }

public static void sortList() { int i; Entry temp; temp = new Entry();

for (int j = 0; j < num_entries; j++) { for (i = j + 1; i < num_entries; i++) { if (entryList[j].name.compareToIgnoreCase(entryList[i].name) > 0) { //Swap the entries if their names are not in ascending order temp = entryList[j]; entryList[j] = entryList[i]; entryList[i] = temp; } } } System.out.println("Sorted the list. Press l to list all the items"); }

public static void CopyInventoryToFile(String FileName) throws Exception { FileOutputStream out = new FileOutputStream(FileName); PrintStream P = new PrintStream(out);

for (int i = 0; i < num_entries; i++) { P.println(entryList[i].name + "\t" + entryList[i].quantity + "\t" + entryList[i].note); } } public static boolean isInteger(String quantity) { Boolean digit = true; int yourNumber;

for (int i = 0; i < num_entries; i++) { try { yourNumber = Integer.parseInt(quantity); } catch (NumberFormatException ex) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setContentText("Invalid input. Quantity must be an integer. Quantity set to 0 by default."); digit = false; } } if (debug) { System.out.println(digit); } return digit; } }

package project_7_main;

import javafx.geometry.Insets; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.stage.Stage; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.control.Alert; import javafx.scene.control.ButtonBar.ButtonData; import javafx.scene.control.ButtonType; import javafx.scene.control.Dialog; import javafx.scene.control.ListView; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.control.TextInputDialog; import javafx.scene.effect.DropShadow; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.util.Pair;

public class VisualInterface {

public static ObservableList results = FXCollections.observableArrayList(); public static Label findName = new Label(); public static String editItem;

public static VBox getVBox() { VBox leftColumn = new VBox(15); leftColumn.setStyle("-fx-background-image: url('http://images.freeimages.com/images/premium/previews/1932/19323130-fruits-and-vegetables-background.jpg');" + "-fx-border-width: 5;" + "-fx-insets: 10;" + "-fx-border-radius: 5;" + "-fx-border-color: white;");

Label optionLabel = new Label("Options"); DropShadow shadow = new DropShadow(); shadow.setOffsetX(5.0); shadow.setOffsetY(5.0); leftColumn.setPrefSize(200, 600); leftColumn.setSpacing(40); leftColumn.setPadding(new Insets(15, 5, 5, 5)); optionLabel.setMinWidth(100); optionLabel.setFont(new Font("Rockwell Extra Bold", 35)); optionLabel.setTextFill(Color.WHITE); optionLabel.setEffect(shadow); leftColumn.getChildren().add(optionLabel);

Button btE = new Button("Enter"); Button btF = new Button("Find"); Button btD = new Button("Delete"); Button btL = new Button("List All"); Button btQ = new Button("Save"); Button[] options = {btE, btF, btD, btL, btQ};

for (int i = 0; i < options.length; i++) { VBox.setMargin(options[i], new Insets(0, 0, 0, 15)); leftColumn.getChildren().add(options[i]); options[i].setStyle("-fx-font: 30 Rockwell"); options[i].setMinWidth(150); } //------Handlers for 1st Enter Buttons----------------------// btE.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } VBox enterBox = enterPane(); pane.getChildren().clear(); pane.getChildren().addAll(leftColumn, enterBox);

//Project_7_Main.addItem(); });

btF.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println(); } VBox findBox = findPane(); pane.getChildren().clear(); pane.getChildren().addAll(leftColumn, findBox); }); btD.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } VBox deleteBox = deletePane(); pane.getChildren().clear(); pane.getChildren().addAll(leftColumn, deleteBox); }); btL.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } VBox listBox = listPane(); pane.getChildren().clear(); pane.getChildren().addAll(leftColumn, listBox); }); btQ.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } VBox saveBox = savePane(); pane.getChildren().clear(); pane.getChildren().addAll(leftColumn, saveBox); });

return leftColumn; }

public static VBox enterPane() { // Create the custom dialog. Dialog> dialog = new Dialog<>(); dialog.setTitle("Enter an item");

// Set the picture (must be included in the project). //ImageView imageView = new ImageView(new Image("login.png")); // Set the button types. Button btnEnter = new Button("Enter"); btnEnter.setMinSize(60, 40); Button btnCancel = new Button("Cancel"); btnCancel.setMinSize(60, 40);

VBox vBoxE = new VBox(15); vBoxE.setPadding(new Insets(15, 15, 15, 15)); vBoxE.setPrefSize(500, 350); vBoxE.setStyle("-fx-background-color: red;" + "-fx-border-width: 5;" + "-fx-insets: 10;" + "-fx-border-radius: 5;" + "-fx-border-color: gold;");

Label paneLabel = new Label("Enter an item"); paneLabel.setMinWidth(300); paneLabel.setFont(new Font("Rockwell Extra Bold", 25)); HBox label = getHBox(); label.getChildren().add(paneLabel);

TextField name = new TextField(); name.setMinWidth(400); Label nameLabel = new Label("Item: "); nameLabel.setMinWidth(100); nameLabel.setFont(new Font("Rockwell", 20)); HBox enterItem = getHBox(); enterItem.getChildren().addAll(nameLabel, name);

TextField quantity = new TextField(); quantity.setMinWidth(400); Label numLabel = new Label("Quantity: "); numLabel.setMinWidth(100); numLabel.setFont(new Font("Rockwell", 20)); HBox enterNum = getHBox(); enterNum.getChildren().addAll(numLabel, quantity);

TextArea notes = new TextArea(); notes.setMinWidth(400); notes.setWrapText(true); notes.setMinHeight(250); Label notesLabel = new Label("Notes: "); notesLabel.setMinWidth(100); notesLabel.setFont(new Font("Rockwell", 20)); HBox enterNotes = getHBox(); enterNotes.getChildren().addAll(notesLabel, notes);

HBox buttons = getHBox(); buttons.setTranslateX(350); buttons.getChildren().addAll(btnEnter, btnCancel);

vBoxE.getChildren().addAll(label, enterItem, enterNum, enterNotes, buttons); vBoxE.setTranslateX(200);

btnEnter.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } entryList[num_entries] = new Entry(); entryList[num_entries].name = name.getText(); entryList[num_entries].quantity = quantity.getText(); entryList[num_entries].note = notes.getText(); if (Project_7_main.debug) { System.out.println(entryList[num_entries].name + entryList[num_entries].quantity + entryList[num_entries].note); } num_entries++; enterPane().getChildren().clear(); pane.getChildren().add(enterPane()); }); btnCancel.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } pane.getChildren().remove(vBoxE); }); return vBoxE; }

public static VBox findPane() { VBox vBoxF = new VBox(15); vBoxF.setPadding(new Insets(15, 15, 15, 15)); vBoxF.setPrefSize(500, 350);

Button btnEdit = new Button("Edit"); btnEdit.setMinSize(60, 40); Button btnCancel = new Button("Cancel"); btnCancel.setMinSize(60, 40);

Label paneLabel = new Label("Enter an item"); paneLabel.setMinWidth(300); paneLabel.setFont(new Font("Rockwell Extra Bold", 30)); HBox label = getHBox(); label.getChildren().add(paneLabel);

TextField findItem = new TextField(); findItem.setMinWidth(300); Label nameLabel = new Label("Item: "); nameLabel.setMinWidth(75); nameLabel.setFont(new Font("Rockwell", 20)); HBox enterItem = getHBox(); enterItem.getChildren().addAll(nameLabel, findItem);

HBox buttons = getHBox(); buttons.setTranslateX(350); buttons.getChildren().addAll(btnEdit, btnCancel);

ListView findResults = new ListView(); findResults.setMinWidth(395); findResults.setTranslateX(15); findResults.setMinHeight(300); results.clear(); findResults.setItems(results);

vBoxF.getChildren().addAll(label, enterItem, findResults, buttons); vBoxF.setTranslateX(200);

if(Project_7_main.debug) findResults.setItems(results); findItem.setOnKeyReleased((KeyEvent event) -> { results.clear(); Project_7_Main.find(findItem.getText()); if (Project_7_main.debug) { System.out.println(results); } findResults.setItems(results); }); findResults.setOnMouseClicked((MouseEvent m) -> { editItem = findResults.getSelectionModel().getSelectedItem().toString(); }); btnEdit.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } findName.setText(findResults.getSelectionModel().getSelectedItem().toString()); if (Project_7_main.debug) { System.out.println(findResults.getSelectionModel().getSelectedItem().toString()); } for (int i = 0; i < num_entries; i++) { if (editItem.toLowerCase().contains(entryList[i].name.toLowerCase()) || entryList[i].name.toLowerCase().contains(editItem.toLowerCase())) { pane.getChildren().remove(vBoxF); pane.getChildren().add(editPane()); } } }); btnCancel.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } pane.getChildren().remove(vBoxF); }); return vBoxF; }

public static VBox editPane() { // Set the button types. Button btnEnter = new Button("Enter"); btnEnter.setMinSize(60, 40); Button btnCancel = new Button("Cancel"); btnCancel.setMinSize(60, 40);

VBox vBoxEt = new VBox(15); vBoxEt.setPadding(new Insets(15, 15, 15, 15)); vBoxEt.setPrefSize(500, 350); vBoxEt.setStyle("-fx-background: gold");

findName.setMinWidth(300); findName.setFont(new Font("Rockwell Extra Bold", 25)); HBox label = getHBox(); label.getChildren().add(findName);

TextField quantity = new TextField(); for (int i = 0; i < num_entries; i++) { if(findName.getText().toLowerCase().contains(entryList[i].name.toLowerCase())) quantity.setText(entryList[i].quantity); } quantity.setMinWidth(300); Label numLabel = new Label("Quantity: "); numLabel.setMinWidth(75); numLabel.setFont(new Font("Rockwell", 15)); HBox enterNum = getHBox(); enterNum.getChildren().addAll(numLabel, quantity);

TextArea notes = new TextArea(); for (int i = 0; i < num_entries; i++) { if(findName.getText().toLowerCase().contains(entryList[i].name.toLowerCase())) notes.setText(entryList[i].note); } notes.setMinWidth(300); notes.setWrapText(true); notes.setMinHeight(250); Label notesLabel = new Label("Notes: "); notesLabel.setMinWidth(75); notesLabel.setFont(new Font("Rockwell", 15)); HBox enterNotes = getHBox(); enterNotes.getChildren().addAll(notesLabel, notes);

HBox buttons = getHBox(); buttons.setTranslateX(350); buttons.getChildren().addAll(btnEnter, btnCancel);

vBoxEt.getChildren().addAll(label, enterNum, enterNotes, buttons); vBoxEt.setTranslateX(200);

btnEnter.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) System.out.println("clicked"); for (int i = 0; i < num_entries; i++) { if(findName.getText().toLowerCase().contains(entryList[i].name.toLowerCase())) { entryList[i].quantity = quantity.getText(); entryList[i].note = notes.getText(); } } try { CopyInventoryToFile("inventory.txt"); }catch (Exception er){ Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error"); alert.setContentText("There was a problem saving your changes!"); } }); btnCancel.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } pane.getChildren().remove(vBoxEt); }); return vBoxEt; }

public static VBox listPane() { VBox vBoxL = new VBox(15); vBoxL.setPadding(new Insets(15, 15, 15, 15)); vBoxL.setPrefSize(500, 350); vBoxL.setStyle("-fx-background: gold");

Button btnEnter = new Button("Edit"); btnEnter.setMinSize(60, 40); Button btnCancel = new Button("Cancel"); btnCancel.setMinSize(60, 40); Button btnSort = new Button("Sort"); btnSort.setMinSize(60, 40);

Label paneLabel = new Label("All Items"); paneLabel.setMinWidth(300); paneLabel.setFont(new Font("Rockwell Extra Bold", 30)); HBox label = getHBox(); label.getChildren().add(paneLabel);

ListView allResults = new ListView(); allResults.setMinWidth(395); allResults.setTranslateX(15); allResults.setMinHeight(300); results.clear(); find(""); allResults.setItems(results);

HBox buttons = getHBox(); buttons.setTranslateX(300); buttons.getChildren().addAll(btnSort, btnEnter, btnCancel);

vBoxL.getChildren().addAll(label, allResults, buttons); vBoxL.setTranslateX(200); allResults.setOnMouseClicked((MouseEvent m) -> { editItem = allResults.getSelectionModel().getSelectedItem().toString(); }); btnSort.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) System.out.println("clicked"); Project_7_Main.sortList(); pane.getChildren().remove(vBoxL); pane.getChildren().add(listPane()); }); btnEnter.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } findName.setText(allResults.getSelectionModel().getSelectedItem().toString()); if (Project_7_main.debug) { System.out.println(allResults.getSelectionModel().getSelectedItem().toString()); } pane.getChildren().remove(vBoxL); pane.getChildren().add(editPane()); }); btnCancel.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } pane.getChildren().remove(vBoxL); }); return vBoxL; }

public static VBox deletePane() { VBox vBoxD = new VBox(15); vBoxD.setPadding(new Insets(15, 15, 15, 15)); vBoxD.setPrefSize(500, 350); vBoxD.setStyle("-fx-background: gold;");

Button btnDelete = new Button("Delete"); btnDelete.setMinSize(60, 40); Button btnCancel = new Button("Cancel"); btnCancel.setMinSize(60, 40);

Label paneLabel = new Label("Enter an item to delete"); paneLabel.setMinWidth(500); paneLabel.setFont(new Font("Rockwell Extra Bold", 30)); HBox label = getHBox(); label.getChildren().add(paneLabel);

TextField delete = new TextField(); delete.setMinWidth(300); Label nameLabel = new Label("Item: "); nameLabel.setMinWidth(75); nameLabel.setFont(new Font("Rockwell", 20)); HBox deleteItem = getHBox(); deleteItem.getChildren().addAll(nameLabel, delete);

HBox buttons = getHBox(); buttons.setTranslateX(350); buttons.getChildren().addAll(btnDelete, btnCancel);

ListView items = new ListView(); items.setMinWidth(395); items.setTranslateX(15); items.setMinHeight(300); results.clear(); items.setItems(results);

vBoxD.getChildren().addAll(label, deleteItem, items, buttons); vBoxD.setTranslateX(200); items.setOnMouseClicked((MouseEvent m) -> { editItem = items.getSelectionModel().getSelectedItem().toString(); }); delete.setOnKeyReleased((KeyEvent event) -> { results.clear(); Project_7_Main.find(delete.getText()); if (Project_7_main.debug) { System.out.println(results); } items.setItems(results); }); btnDelete.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } Project_7_Main.delete(delete.getText()); items.setItems(results); }); btnCancel.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } pane.getChildren().remove(vBoxD); });

return vBoxD; }

public static VBox savePane() { VBox vBoxS = new VBox(15); vBoxS.setPadding(new Insets(15, 15, 15, 15)); vBoxS.setPrefSize(500, 350); vBoxS.setStyle("-fx-background: gold");

Button btnOk = new Button("OK!"); btnOk.setMinSize(60, 40);

Label paneLabel = new Label("Items saved!"); paneLabel.setMinWidth(300); paneLabel.setAlignment(Pos.CENTER); paneLabel.setFont(new Font("Rockwell Extra Bold", 30)); HBox label = getHBox(); label.getChildren().add(paneLabel);

HBox buttons = getHBox(); buttons.setTranslateX(400); buttons.getChildren().addAll(btnOk);

vBoxS.getChildren().addAll(label, buttons); vBoxS.setTranslateX(200); btnOk.setOnAction((ActionEvent e) -> { if (Project_7_main.debug) { System.out.println("clicked"); } pane.getChildren().remove(vBoxS); });

return vBoxS; }

public static HBox getHBox() { HBox hBox = new HBox(15); hBox.setPadding(new Insets(15, 15, 15, 15)); hBox.setStyle("-fx-background: gold"); return hBox; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions