Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this example I developed code but I can not get the buttons to become exclusive to one another and can not get the final

In this example I developed code but I can not get the buttons to become exclusive to one another and can not get the final button for on-location to add the price onto the previous price, it is overriding the solution instead. Here is the assignment and the code that I have developed.

"Develop an interactive Java Swing application for Paula's Portraits, a photography studio.

Submit the following program: Develop a class named PhotoStudio based on JFrame container containing the proper Swing controls to allow a user to enter her/his name, phone number, email, and to compute the price of a photography session. The base price is $40 for an in-studio photo session with one person. The in-studio fee is $75 for a session with two or more subjects, and $95 for a session with a pet. A $90 fee is added to take photos on location instead of in the studio.

Place and use the following controls: textboxes to enter the customer name, phone number, and email. Include a set of mutually exclusive check boxes to select the portrait subject and another set for the session location. Include labels as appropriate to explain the application's functionality. Select and use a proper layout manager to enable an orderly arrangement of the controls on the JFrame. Add a "Create estimate" JButton which, when clicked, should generate the summary of the order and display in a JTextArea. The summary should include the customer information, order details (selections made), and the total calculated price of the order. Save your work in the PhotoStudio,java file."

Here is the code I have

class PhotoStudio extends javax.swing.JFrame {

int estimate;String name,phn,email; public PhotoStudio() { initComponents(); } @SuppressWarnings("unchecked") private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jTextField3 = new javax.swing.JTextField(); jCheckBox1 = new javax.swing.JCheckBox(); jCheckBox2 = new javax.swing.JCheckBox(); jCheckBox3 = new javax.swing.JCheckBox(); jScrollPane1 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); jButton1 = new javax.swing.JButton(); jCheckBox4 = new javax.swing.JCheckBox(); jLabel4 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("PhotoStudio Estimator"); jLabel1.setText("Name"); jLabel2.setText("Phone Number"); jLabel3.setText("Email"); jCheckBox1.setText("In-Studio(1 Subject)"); jCheckBox2.setText("In-Studio(2 or More Subjects)"); jCheckBox3.setText("In-Studio(with Pet)"); jTextArea1.setColumns(20); jTextArea1.setRows(5); jScrollPane1.setViewportView(jTextArea1); jButton1.setText("Create Estimate"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });

jCheckBox4.setText("On-Location"); jLabel4.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N jLabel4.setText("PhotoStudio Estimator");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(29, 29, 29) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel3)) .addGap(26, 26, 26) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE) .addComponent(jTextField1) .addComponent(jTextField2))) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jCheckBox1) .addComponent(jCheckBox2) .addComponent(jCheckBox3) .addComponent(jButton1) .addComponent(jCheckBox4))) .addGroup(layout.createSequentialGroup() .addGap(135, 135, 135) .addComponent(jLabel4))) .addContainerGap(10, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4) .addGap(13, 13, 13) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCheckBox1)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCheckBox2)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCheckBox3)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(layout.createSequentialGroup() .addGap(30, 30, 30) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18) .addComponent(jCheckBox4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton1))) .addContainerGap(34, Short.MAX_VALUE)) );

pack(); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { name=jTextField1.getText(); phn=jTextField2.getText(); email=jTextField3.getText(); if(jCheckBox1.isSelected()) { estimate=40; } if(jCheckBox2.isSelected()) { estimate=75; } if(jCheckBox3.isSelected()) { estimate=95; } if(jCheckBox4.isSelected()) { estimate=90; } jTextArea1.setText("Name:"+name+" Phone Number:"+phn+" Email ID:"+email+" Estimate:$"+estimate); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(() -> { new PhotoStudio().setVisible(true); }); } private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton jButton1; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JCheckBox jCheckBox2; private javax.swing.JCheckBox jCheckBox3; private javax.swing.JCheckBox jCheckBox4; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; private javax.swing.JTextField jTextField3; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To make the buttons exclusive to one another so only one can be selected at a time you need to use a ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions