/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * exercicio_7.java * * Created on 7/Jul/2010, 10:27:16 */ package exercicio_7; /** * * @author Nelson */ public class exercicio_7 extends javax.swing.JApplet { /** Initializes the applet exercicio_7 */ public void init() { try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { initComponents(); } }); } catch (Exception ex) { ex.printStackTrace(); } } /** This method is called from within the init() method to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton2 = new javax.swing.JRadioButton(); jRadioButton3 = new javax.swing.JRadioButton(); jRadioButton4 = new javax.swing.JRadioButton(); jRadioButton5 = new javax.swing.JRadioButton(); jRadioButton6 = new javax.swing.JRadioButton(); jRadioButton7 = new javax.swing.JRadioButton(); jRadioButton8 = new javax.swing.JRadioButton(); jButton1 = new javax.swing.JButton(); jLabel11 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jTextField3 = new javax.swing.JTextField(); jButton3 = new javax.swing.JButton(); jTextField4 = new javax.swing.JTextField(); jLabel16 = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel(); jTextField5 = new javax.swing.JTextField(); getContentPane().setLayout(null); jLabel1.setText("Betão Qualidade"); getContentPane().add(jLabel1); jLabel1.setBounds(10, 130, 100, 40); jLabel2.setText("Desconto"); getContentPane().add(jLabel2); jLabel2.setBounds(10, 240, 60, 20); jLabel3.setText("C20/25"); getContentPane().add(jLabel3); jLabel3.setBounds(10, 170, 40, 20); jLabel4.setText("C25/30"); getContentPane().add(jLabel4); jLabel4.setBounds(130, 170, 40, 14); jLabel5.setText("C30/35"); getContentPane().add(jLabel5); jLabel5.setBounds(250, 170, 40, 14); jLabel6.setText("C12"); getContentPane().add(jLabel6); jLabel6.setBounds(370, 170, 40, 20); jLabel7.setText("3%"); getContentPane().add(jLabel7); jLabel7.setBounds(10, 270, 17, 14); jLabel8.setText("5%"); getContentPane().add(jLabel8); jLabel8.setBounds(120, 270, 17, 14); jLabel9.setText("7%"); getContentPane().add(jLabel9); jLabel9.setBounds(230, 270, 17, 14); jLabel10.setText("10%"); getContentPane().add(jLabel10); jLabel10.setBounds(320, 270, 40, 14); jRadioButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton1ActionPerformed(evt); } }); getContentPane().add(jRadioButton1); jRadioButton1.setBounds(70, 170, 20, 20); jRadioButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton2ActionPerformed(evt); } }); getContentPane().add(jRadioButton2); jRadioButton2.setBounds(200, 170, 21, 21); jRadioButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton3ActionPerformed(evt); } }); getContentPane().add(jRadioButton3); jRadioButton3.setBounds(320, 170, 21, 21); jRadioButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton4ActionPerformed(evt); } }); getContentPane().add(jRadioButton4); jRadioButton4.setBounds(420, 170, 21, 21); jRadioButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton5ActionPerformed(evt); } }); getContentPane().add(jRadioButton5); jRadioButton5.setBounds(60, 270, 21, 21); jRadioButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton6ActionPerformed(evt); } }); getContentPane().add(jRadioButton6); jRadioButton6.setBounds(170, 270, 21, 21); jRadioButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton7ActionPerformed(evt); } }); getContentPane().add(jRadioButton7); jRadioButton7.setBounds(270, 270, 21, 21); jRadioButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButton8ActionPerformed(evt); } }); getContentPane().add(jRadioButton8); jRadioButton8.setBounds(370, 270, 21, 21); jButton1.setText("Calcular"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); getContentPane().add(jButton1); jButton1.setBounds(30, 100, 120, 30); jLabel11.setText("Medida"); getContentPane().add(jLabel11); jLabel11.setBounds(110, 10, 60, 20); jLabel12.setText("Comprimento"); getContentPane().add(jLabel12); jLabel12.setBounds(10, 40, 63, 20); jLabel13.setText("Largura"); getContentPane().add(jLabel13); jLabel13.setBounds(120, 40, 37, 14); jLabel14.setText("Altura"); getContentPane().add(jLabel14); jLabel14.setBounds(210, 40, 29, 14); getContentPane().add(jTextField1); jTextField1.setBounds(10, 70, 60, 20); getContentPane().add(jTextField2); jTextField2.setBounds(110, 70, 60, 20); getContentPane().add(jTextField3); jTextField3.setBounds(200, 70, 60, 20); jButton3.setText("Limpar"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); getContentPane().add(jButton3); jButton3.setBounds(480, 370, 130, 30); jTextField4.setText("Total"); jTextField4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextField4ActionPerformed(evt); } }); getContentPane().add(jTextField4); jTextField4.setBounds(70, 210, 100, 20); jLabel16.setText("Preco"); getContentPane().add(jLabel16); jLabel16.setBounds(20, 330, 40, 14); getContentPane().add(jLabel17); jLabel17.setBounds(30, 220, 70, 0); getContentPane().add(jTextField5); jTextField5.setBounds(160, 100, 80, 30); }// </editor-fold> private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) { float bet,subtotal; bet=Float.parseFloat(jTextField5.getText()); subtotal=bet*50; jTextField4.setText(String.valueOf(+subtotal)); jRadioButton2.setSelected(false); jRadioButton3.setSelected(false); jRadioButton4.setSelected(false); } private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) { float bet,subtotal; bet=Float.parseFloat(jTextField1.getText()); subtotal=(float) (bet * 45); jTextField4.setText(String.valueOf(+subtotal)); jRadioButton2.setSelected(false); jRadioButton1.setSelected(false); jRadioButton3.setSelected(false); // TODO add your handling code here: } private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) { float bet,subtotal; bet=Float.parseFloat(jTextField1.getText()); subtotal=bet*52; jTextField4.setText(String.valueOf(+subtotal)); jRadioButton1.setSelected(false); jRadioButton3.setSelected(false); jRadioButton4.setSelected(false); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { double comp,larg,altu,quant_bet = 0,val_final,desc,subtotal,valor = 0,total; comp=Float.parseFloat(jTextField1.getText()); larg=Float.parseFloat(jTextField2.getText()); altu=Float.parseFloat(jTextField3.getText()); quant_bet=altu*larg*comp; jTextField5.setText(String.valueOf(+quant_bet)); } private void jRadioButton5ActionPerformed(java.awt.event.ActionEvent evt) { float total, desconto; total=Float.parseFloat(jTextField4.getText()); desconto=(float) (total*0.03); jLabel16.setText(String.valueOf(+desconto)); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false); jRadioButton8.setSelected(false); } private void jRadioButton6ActionPerformed(java.awt.event.ActionEvent evt) { float total, desconto; total=Float.parseFloat(jTextField4.getText()); desconto=(float) (total*0.05); jLabel16.setText(String.valueOf(+desconto)); jRadioButton5.setSelected(false); jRadioButton7.setSelected(false); jRadioButton8.setSelected(false); } private void jRadioButton7ActionPerformed(java.awt.event.ActionEvent evt) { float total, desconto; total=Float.parseFloat(jTextField4.getText()); desconto=(float) (total*0.07); jLabel16.setText(String.valueOf(+desconto)); jRadioButton5.setSelected(false); jRadioButton6.setSelected(false); jRadioButton8.setSelected(false); } private void jRadioButton8ActionPerformed(java.awt.event.ActionEvent evt) { float total, desconto; total=Float.parseFloat(jTextField4.getText()); desconto=(float) (total*0.10); jLabel5.setText(String.valueOf(+desconto)); jRadioButton5.setSelected(false); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false); } private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) { float bet,subtotal; bet=Float.parseFloat(jTextField1.getText()); subtotal=(float) (bet * 55.50); jTextField4.setText(String.valueOf(+subtotal)); jRadioButton2.setSelected(false); jRadioButton1.setSelected(false); jRadioButton4.setSelected(false); } private void jTextField4ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { jTextField1.setText(""); jTextField2.setText(""); jTextField3.setText(""); jTextField4.setText(""); jTextField5.setText(""); jRadioButton1.setSelected(false); jRadioButton2.setSelected(false); jRadioButton3.setSelected(false); jRadioButton4.setSelected(false); jRadioButton5.setSelected(false); jRadioButton6.setSelected(false); jRadioButton7.setSelected(false); jRadioButton8.setSelected(false); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JRadioButton jRadioButton1; private javax.swing.JRadioButton jRadioButton2; private javax.swing.JRadioButton jRadioButton3; private javax.swing.JRadioButton jRadioButton4; private javax.swing.JRadioButton jRadioButton5; private javax.swing.JRadioButton jRadioButton6; private javax.swing.JRadioButton jRadioButton7; private javax.swing.JRadioButton jRadioButton8; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; private javax.swing.JTextField jTextField3; private javax.swing.JTextField jTextField4; private javax.swing.JTextField jTextField5; // End of variables declaration }