Answered step by step
Verified Expert Solution
Question
1 Approved Answer
File Edit View Navigate Code Refactor Build Run Tools Git Window Help lab-10-gui-lists-ug2057pz Lab 10 Questions.md Project O Commit Pull Requests Structure AGGIH~~~NAMNHS 55
File Edit View Navigate Code Refactor Build Run Tools Git Window Help lab-10-gui-lists-ug2057pz Lab 10 Questions.md Project O Commit Pull Requests Structure AGGIH~~~NAMNHS 55 G F G F FFGDN Bookmarks 17 18 19 20 21 22 23 24 25 26 | 28 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 MD Main.java X Storage.java Lab 10 Questions.md X ## Task 1: Set up JList Models MD The GUI has two JLists - one for the names of places the user wishes to go to `wishList`, and names of places the user has visited, `visitedList`. These JLists should be lists of Strings. Add the generic type to the two JLists in `WishlistGUI.java` Create and assign a DefaultListModel of Strings for both lists. ## Task 2: Add a new place Add an event listener to the `addButton` JButton. When this button is clicked, read the text entered in `newPlaceNameTextField`. Java_Auto_Grader_10 - Lab 10 Questions.md Add Configuration... If the text is blank for example, empty, or just spaces, then don't do anything. Don't add anything to the `wishList`. If the text is not blank, add the new place to the wishlist model, to add it to the `wishList` JList. Clear the text in newPlace NameTextField`. E**Important!** You must use the `showMessageDialog` method to show a message dialog or the tests will fail. ## Task 3: Marking a place visited Visited! Delete The program should not accept duplicate names. If the place name is already in the `wishList`, then display an alert dialog using the `showMessageDialog` method provided f For this program, you can assume two place names in different cases are the same place. So your program should NOT permit "new york" if "New York" is already in the list. Add a JPopupMenu to the `wishList`. It will have two menu items with this text, Git: The JMenuItems should have the exact text "Visited!" and "Delete". When the user right-clicks on a place and selects "Visited!" the place should be removed from the `wishList` and added to the `visitedList`. TODO Problems Terminal Profiler Dependencies Git Download pre-built shared indexes: Reduce the indexing time and CPU load with pre-built JDK and Maven library shared indexes // Alwa... (39 minutes ago) 58F Cloudy Build > 104:33 CRLF UTF-8 4 spaces main 4:58 PM 5/6/2022 1 Event Log X 2 Database Maven File Edit View Navigate Code Refactor Build Run Tools Git Window Help lab-10-gui-lists-ug2057pz Lab 10 Questions.md Project O Commit Pull Requests K H. Structure > Bookmarks 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 MD MD Main.java X Storage.java Lab 10 Questions.md X ## Task 6: Saving to files Add an event listener to `saveQuitButton` JButton. Add an event handler to the `saveQuitButton` JButton. 58F Cloudy When this button is clicked, call the `Main.quit()` method with a list of places in the `wishList` and a list of places in the `visitedList`. `Main.quit()` expects two lists of Strings as arguments. You'll need to build these lists (for example, ArrayList or LinkedList) of wish list and visited place names. Next, in your `saveQuitButton` event handler in the GUI, call `dispose()` to close the GUI window and end the program. In Storage.java, finish the `writeListToFile` method. Main's `quit` method calls `writeListToFile` once for each list. In `Storage.writeListToFile` write the list of String places to a file, one String per line. Write the lines in the same order as they are displayed in the JList. Overwrite the data in any existing files. Java_Auto_Grader_10 - Lab 10 Questions.md Add Configuration... Use the try-with-resources style of exception handling. The Storage.java `writeListToFile` method should NOT declare it throws any exceptions. ## Task 7: Loading Saved Places Finish the `readListFromFile` method in Storage.java. This method is called by the main method when the program is launched. Write code to read all the Strings from the file given by the filename argument. Add each String to a List, and return the List. Use the try-with-resources style of exception handling. The Storage.java `writeListToFile` method should NOT declare it throws any exceptions. Git: Git TODO Problems Terminal Profiler Dependencies Download pre-built shared indexes: Reduce the indexing time and CPU load with pre-built JDK and Maven library shared indexes // Always ... (44 minutes ago) Build If the filename is not found, or if there are any other IOException thrown, return an empty list. This will allow your program to work with no errors if one or both of the > In WishListGUI.java, the constructor is called with a list of `wishListPlaces`, and a list of `visitedPlaces`. In the constructor, use these lists to add places to the W So, when the program starts, it will read lists of places from file. It will display places read from file in the JLists. When user saves and quits, all the places in the X 70:1 CRLF UTF-8 4 spaces main 5:03 PM 5/6/2022 1 Event Log 2 Database Maven File Edit View Navigate Code Refactor Build Run Iools Git Window Help lab-10-gui-lists-ug2057pz Lab 10 Questions.md Project Commit Pull Requests H. Structure Bookmarks 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 MD Main.java X Storage.java Lab 10 Questions.md X The JMenuItems should have the exact text "Visited!" and "Delete". MD ## Task 4: Deleting a WishList Place When the user right-clicks on a place and selects "Visited!" the place should be removed from the `wishList` and added to the `visitedList`. You added a JPopupMenu for the `wishList` for Task 3. For this task, implement the Delete menu item. When the user right-clicks and selects "Delete" from the menu, remove the place from the `wishList`. Do not show any dialogs, or ask for confirmation. Just remove the place from the `wishlist`. ## Task 5: Deleting a Visited Place Add a JPopupMenu to the `visitedList`. This menu has one item Delete Java_Auto_Grader_10 - Lab 10 Questions.md Add Configuration... Use this exact text for the JMenuItem. When the user right-clicks and selects "Delete" from the menu, remove the place from the `visitedList`. Do not show any dialogs, or ask for confirmation. Just remove the place from the `visitedList`. ## Task 6: Saving to files Add an event listener to `sa QuitButton` JButton. Add an event handler to the `saveQuitButton` JButton. Git: TODO Problems Terminal Profiler Build Dependencies Git Download pre-built shared indexes: Reduce the indexing time and CPU load with pre-built JDK and Maven library shared indexes // Always ... (47 minutes ago) 58F Cloudy 5 70:1 CRLF UTF-8_4 spaces & main I 1 Event Log 5:06 PM 5/6/2022 > X 2 Database Maven
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started