Discussion Section 13: Graphical User Interface
Due: 10pm Tuesday April 24
Purpose: In this discussion
section, you will practice using a graphical user interface.
The template for CoinConverter class is given here. You don't need to use this template, but please do keep the header and fill it out before turning in. The image files used in the example are here. If you prefer, you can provide your own image files. If you are using the template, you only need to complete actionPerformed.
Hint 1: To display the same quarter image many times, you need to create a different JLabel components for each time you want to display it. For example, to add the image of quarter to picturePanel numQuarters times, you can use the following code.
ImageIcon quarterPic = new ImageIcon ("quarter.jpg", "Texas Quarter");
for (int i=0; i < numQuarters; i++) {
JLabel quarter = new JLabel (quarterPic);
picturePanel.add(quarter);
}
Hint 2: the maximum number of quarters that can be displayed is 3, dimes 2, nickels 1, and pennies 4.
Instead of displaying images, you can simply display the coins in text in a response box. (Refer to the code for response box from the lecture examples.) The response box should display error message if the input is less than 0, or greater than 99. You will get full credit if you implement response box, but will get extra credit (10 pts) for using images. Also, you will get extra credit (10pts) for aligning coins in each type, i.e., quarters in the top row, dimes in the second row, nickels in the third row, and pennies in the fourth row.
Your will turn in a file named CoinConverter.java. In case you implement the GUI version of CoinConverter, please upload the image files too.
Your program should be internally correct (sound logic) and
externally correct (following Java style
guideline).