Homework 10

Write a program with a graphical user interface that allows the user to enter the attributes for a car. When the user clicks the OK button, the attributes entered by the user will be used to create a Car object (using your latest Car class from lab 5). The toString method of the Car object will be used to set the text in the non-editable text area located below the OK button. When the user clicks the Exit button, the application will terminate. A sample run is shown below. The text displayed in your text area will probably look different than mine since you were free to choose your own format for the string returned by the toString method of the Car class.

Sample Run

In my application, the text fields are all size 20 and the text area is 4 rows by 20 columns. The initial application window will be very wide if you use a FlowLayout so you'll have to play around with it to get it to look like the sample run above.

Bonus Points

I'll give you 5 bonus points if your application's interface looks like the illustration below when it is run (with no resizing necessary). It uses a GridBagLayout. The two command buttons are in a JPanel that uses a GridLayout (to make the buttons the same width). This panel is added to the application frame rather than adding the buttons individually.

Sample Run

Submitting Your Work

Send me your Hmwk10.java file and your most recent Car.java file as attachments to an email message whose subject is "Hmwk10".