Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Looking for some help hard-coding a calculator GUI. Instructions and examples listed below. Any help would be appreciated!! 1. CODE] [100pts] Create a simple GUI
Looking for some help hard-coding a calculator GUI. Instructions and examples listed below. Any help would be appreciated!!
1. CODE] [100pts] Create a simple GUI using only code (i.e., you may not use WindowBuilder or any other designer for this particular problem, just to make sure we understand the basics) that replicates a simple calculator Have a custom title . Use the FlowLayout layout manager Have 3 labels (JLabel) . Have 3 text boxes (JTextField) o Try instantiating with "new JTextFiel10)" to give reasonable size Have 4 buttons (JButton) . Should look similar to the images below Your GUI should adhere to the following functional requirements The first two text boxes on the left represent two operands The four buttons represent four arithmetic operations (+,-, *,/) . o When a button is pressed, if either of the values in the operand text boxes is not a number, then warn the user with a popup message and set the last label and text box to "N/A" HINT: You will need to catch an exception after a parseDouble fails o When the divide button is pressed, if the second operand is 0, then warn the user with a popup message and set the last label and text box to "N/A" To display an error message, try JOptionPane.showMessageDialog(null, "Message", Title", JOptionPane ERROR MESSAGE)," . The last label represents the expression Should be initialized to "Answer:" o o Should be set to the expression after each button click The last text box represents the answer: . o Should not be editable (try setEditable(false)) Should have red text if its value is negative, black otherwise oStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started