Homework 12: Complex GUIs Solved

30.00 $

Category:

Description

Homework 12: Complex GUIs Solved
5 (100%) 1 vote

Goals:

  • Learn how to apply the MVC paradigm
  • Learn how to handle events
  • Learn how to add functionality to Swing components

 

Introduction:

While working in the terminal for an eternity may be appealing to some, most users would like to interact with a graphical user interface, or GUI. GUIs, nowadays, can be found anywhere and everywhere — on our laptops, on our phones, at fast food locations, et cetera. They have made, and continue to make, computers easier to use for everyone.

The Java Programming Language offers built-in libraries to create graphical user interfaces, in the form of AWT and Swing, with Swing being the newer of the two. One of the nice things about these libraries is that they are cross-platform. If you create an application on your Mac, the same application can run seamlessly on your friend’s Windows machine.  

Description

An IntelliJ project has been provided for you as skeleton code and is accessible from the course webpage. This project contains classes and methods that have already been declared for you. All you need to do is add implementations where you find TODO comments in AddController​, ​EditController​, ​DeleteController​, and ​SearchController​. When you would like to run the application, you may do so by clicking the green arrow in the MessageBoardRunner class — this is where main() is declared. If you have any issues with setting this up in IntelliJ, please post on Campuswire.

This application is similar to a Twitter feed or message board. Rather than have a user go through a terminal and manually organize a list of text files or messages, we are designing a GUI to allow a user to easily add, delete, edit, and search for tweets. Each tweet will have a unique numeric ID (1, 2, … 17). Our GUI will include four tabs corresponding to the classes in bold above. Your task is to implement each of the methods described below. Starter code is available on Blackboard, and you should not begin working until you have downloaded and read through it.

For a better understanding of the Model View Controller (MVC) paradigm, you can read about it ​here. Note that the CS180 team does not condone underage drinking ;).

 

 

AddController.java

  1. public AddController(): Implement the constructor method for this class. This should​ throw an IllegalArgumentException if either argument is null. This is where you will add the functionality of the buttons. If you get stuck, try doing some googling for how Swing components use “ActionListeners”.

 

  1. private void getAddButtonSemantics(): This method gets called when the user​ presses ‘Add Tweet’ button, it checks the tweet ID, and if it is not numeric or negative, it displays an error message (The specified ID is not a valid number!), and moves the cursor to this text field in the form. If the ID is valid, it proceeds to adding this tweet to the tweetList, and then displays either a successful message if successfully posted, or an error message otherwise. Reminder that Tweet ID’s must also be unique.

 

  1. public void getClearButtonSemantics(): This method is called to clear the fields in a​ panel of all text and put the cursor back on the ID field.

EditController.java

  1. public EditController(): Follow the same instructions for the AddController instructor,​ but instead of adding a tweet to our tweetList, we will edit the contents of an existing tweet.

 

  1. private void getEditButtonSemantics(): This method gets called when the user​ presses ‘Edit Tweet’ button, it checks the tweet ID, and if it is does not exist, it displays an error message (A message with the given ID does not exist!). If the ID exists, it proceeds to editing this tweet, reading the new body entered by the user, updating it and then displays a successful message for the user. If the edited text is left empty, show a message that suggests the user delete the Tweet instead. If the Tweet is successfully edited, display a message dialog accordingly.

 

  1. private void getClearButtonSemantics(): Clear the fields in the panel and reset the​ cursor to the body text field.

 

 

 

 

             

DeleteController.java

  1. public DeleteController():​ Follow the same instructions per the two previous constructor methods. Rather than adding or editing a tweet to our tweetList, we will be removing a tweet based on the ID input.

 

  1. private void getDeleteButtonSemantics(): ​This method gets called when the user presses ‘Delete Tweet’ button, it checks the tweet ID, and if it is does not exist, it displays an error message (A message with the given ID does not exist!). If the ID exists, it proceeds to deleting this tweet, and then displays a success message for the user. It also clears all fields in this form. You can assume there will be no null input.

 

  1. public void getClearButtonSemantics(): ​This method is called to clear the fields in a panel of all text and put the cursor back on the ID field.

SearchController.java

*​You may create additional methods within SearchController in order to complete this task

  1. public SearchController(): ​Follow the same instructions per the other constructors.

 

  1. private void getSearchButtonSemantics():​ Similar to the other semantic methods, write this method in order to search for a given tweet by using a search phrase. You can assume the phrase used to search will always be a valid String and will not be null. By pressing the ‘Search’ button, a list should show up in the ​IDTextArea​, separating each Tweet ID that contained the search phrase to a new line. You should check to see if the search phrase is empty and display an error message accordingly.

Submission

Items required for Submission via Blackboard:

  • Resubmit all files provided in the skeleton code.
  • GRADING IS MANUAL FOR THIS ASSIGNMENT!