Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
Create a class named Assignment2 which provides a GUI window for entering, storing, and viewing user input.
Create a class named Assignment2 which provides a GUI window for entering, storing, and viewing user input. In the GUI, buttons will be used to accept user commands and text fields will be used to accept user input data and display data to the user.
1) The Assignment2 data fields:
a) an int[] array named data, which should be initialized in the constructor as a size zero array
b) an int named index, which holds the value of the index of data currently being viewed and should be initialized to -1
c) one JTextField, for user input, which should be initialized as blank (no text) and editable
d) two JLabels:
i) the value of index, in the format "showing index index of data.length"
ii) one displaying the value of data[index], unless (index == -1) - then, leave it blank
e) five JButtons, labeled appropriately, for processing the commands:
i) add: expands data to hold another element, reads the value from the JTextField, assigns the new element that value, then clears the JTextField text.
ii) remove: compacts data to remove the element stored at data[index]. The new array (still data) should retain all other elements in their original order. Removing an array element will decrement index and refresh the two JLabels.
iii) up: increases index by one and refreshes the two JLabels. However, in the event that (index == data.length - 1), then no change happens.
iv) down: decreases index by one and refreshes the two JLabels. However, in the event that (index == -1), then no change.
v) filter: compacts data to remove all negative values; if any negative values are removed, the JLabels should be refreshed. The index field should decrease by the number of elements removed with indexes < index. The new array (still data) should retain all other elements in their original order.
Filter example: Given index = 3 and data = { -1, 0, -2, 3, 4, 7, -9}, two negatives are below the value 3 at index 3, so filtering gives index = 1 and data = {0, 3, 4, 7}.
2) Assignment2 methods:
a) a constructor that creates the GUI window and makes it visible to the user and performs the initializations given in 1), above
b) a main method that creates an Assignment2 object
c) a separate method for each of the five commands in 1e), above
d) actionPerformed (from the ActionListener interface) that determines which JButton was pressed and calls the appropriate method from 2c), above
e) you may choose to use separate methods for refreshing JLabels and changing the array size
3) GUI structure & checks:
a) You have latitude to build the GUI in any convenient style, as long as it is obvious where the components are and what they do
b) Although JPanels are not specified as data fields, you should use them and perhaps a layout manager to style your GUI
c) Each application will be tested by creating an array through the GUI and executing a standard command script. It is recommended that you test your application by entering a mix of negative and non-negative numbers, then removing and filtering them.
d) You will need to provide exception handling for user inputs to ensure they are of type int. When a user attempts to add an invalid input, the JTextField text should be cleared but no other action or notification needs to take place (and, of course, the program should not crash).