Description
To start with, you need to build a simple GUI that allows the wine Merchant to process the incoming orders from suppliers.
The Merchant has been very erratic. It is quite hard for the Merchant to remember how much they paid for the incoming orders. At this stage, you should have a simple program that allows the merchant to input an order, note the supplier's name, and add it to the inventory. There are three varieties of wine: White Sauvignon, Red Merlot, and Rosé Zinfandel. Wine comes in cases, each is 12 bottles, so keep it in mind when calculating the total number of bottles in the inventory.
For example — Merlot, the supplier is Wineotech, the amount is three cases. After this, your program should display a table with the order and the total number of bottles (36 bottles of Merlot).
Objectives
At this stage your program should:
- Contain a Swing window with three options (one for each variety of wine).
- Once the wine is set, output a second panel which should prompt a separate text box to input the number of cases (minimum
1, maximum10). - After this, prompt with a text box to enter the name of the supplier.
- Display a success message with a
JLabel. Call itSuccessLabel.
If you want to pass the tests, name your Swing elements in the following way. You can use the setName() function for this:
- For the wine varieties, use
JRadioButtonsand make sure you name them asMerlotButton,RoseButton, andSauvignonButton. - Name three
JPanelsasTopPanel,MiddlePanel, andBottomPanel. - Name three labels as
InstructionLabel,MessageLabel, andSuccessLabel. - Name two
JComboBoxasAmountComboBoxandSupplierComboBoxfor the dropdown options while populating an order. - Name one
JTextFieldasPurchasedPriceTextFieldwhere users can input the price for an order. - Name one
JButtonasSubmitButtonwhich can be pressed to input the order.
Design the GUI components as described:
- The
JFrameshould be titled "Wine Merchant". - The
TopPanelshould containInstructionLabeland buttons to select wine varieties;MerlotButton,RoseButton,SauvignonButton, which should be placed within aButtonGroupso that only one button can be pressed at a time. - The
InstructionLabelshould prompt the user to select a type of wine with the text"Select the type of wine:". - The
MiddlePanelshould containAmountComboBox,SupplierComboBoxandPurchasedPriceTextField. - The
MiddlePanelshould not be visible at first. When the user selects a particular wine type theMiddlePanelshould become visible along with all the components within it. - The
AmountComboBoxshould have options to select the number of cases of wine (minimum1, maximum10). - The
SupplierComboBoxshould be set to be editable to allow input of various supplier names. However, the supplier names should be validated to contain only alphabets. ThisJComboBoxshould be capable of storing valid input data for future use. - The
PurchasedPriceTextFieldshould take only numeric values as input. However, they may contain.to signify decimal points. - The
BottomPanelshould containSuccessLabel,SubmitButtonandMessageLabel. - The
SubmitButtonwhen pressed should evaluate the input data. When the data is correct theMiddlePanelshould be set to invisible, the button itself should be disabled,SuccessLabelwith the text"Success!"should be shown andMessageLabelwith the text"Added n cases of typeofwine from suppliername (n*12 bottles). - In case of an incorrect evaluation of input data,
MessageLabelshould show an error message with the string"Error"in it. - Also, keep in mind to clear the input field in
AmountComboBoxandPurchasedPriceTextFieldwhen theSubmitButtonis pressed.
Examples
Example 1: wine variety selection
Example 2: the amount selection
Example 3: success!