Untitled
unknown
plain_text
7 months ago
47 kB
3
Indexable
Never
public class CalculadoraView extends javax.swing.JFrame { //variables String numero1; String numero2; String signo; public CalculadoraView() { initComponents(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jToggleButton1 = new javax.swing.JToggleButton(); jToggleButton2 = new javax.swing.JToggleButton(); jToggleButton3 = new javax.swing.JToggleButton(); jToggleButton4 = new javax.swing.JToggleButton(); jToggleButton5 = new javax.swing.JToggleButton(); jToggleButton6 = new javax.swing.JToggleButton(); jToggleButton7 = new javax.swing.JToggleButton(); jToggleButton8 = new javax.swing.JToggleButton(); jToggleButton9 = new javax.swing.JToggleButton(); jToggleButton10 = new javax.swing.JToggleButton(); jToggleButton11 = new javax.swing.JToggleButton(); jToggleButton12 = new javax.swing.JToggleButton(); jToggleButton13 = new javax.swing.JToggleButton(); jToggleButton14 = new javax.swing.JToggleButton(); jToggleButton15 = new javax.swing.JToggleButton(); jToggleButton16 = new javax.swing.JToggleButton(); jToggleButton17 = new javax.swing.JToggleButton(); jToggleButton18 = new javax.swing.JToggleButton(); jToggleButton19 = new javax.swing.JToggleButton(); jToggleButton20 = new javax.swing.JToggleButton(); jToggleButton21 = new javax.swing.JToggleButton(); jToggleButton22 = new javax.swing.JToggleButton(); jToggleButton23 = new javax.swing.JToggleButton(); jToggleButton24 = new javax.swing.JToggleButton(); jToggleButton25 = new javax.swing.JToggleButton(); jToggleButton26 = new javax.swing.JToggleButton(); jToggleButton27 = new javax.swing.JToggleButton(); jToggleButton28 = new javax.swing.JToggleButton(); jToggleButton29 = new javax.swing.JToggleButton(); jToggleButton30 = new javax.swing.JToggleButton(); jToggleButton31 = new javax.swing.JToggleButton(); jToggleButton32 = new javax.swing.JToggleButton(); jToggleButton33 = new javax.swing.JToggleButton(); jToggleButton34 = new javax.swing.JToggleButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setBackground(new java.awt.Color(255, 255, 255)); jLabel1.setBackground(new java.awt.Color(153, 153, 153)); jLabel1.setFont(new java.awt.Font("DejaVu Sans", 0, 24)); // NOI18N jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true)); jLabel1.setOpaque(true); jToggleButton1.setText("1"); jToggleButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton1ActionPerformed(evt); } }); jToggleButton2.setText("2"); jToggleButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton2ActionPerformed(evt); } }); jToggleButton3.setText("3"); jToggleButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton3ActionPerformed(evt); } }); jToggleButton4.setText("4"); jToggleButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton4ActionPerformed(evt); } }); jToggleButton5.setText("5"); jToggleButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton5ActionPerformed(evt); } }); jToggleButton6.setText("6"); jToggleButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton6ActionPerformed(evt); } }); jToggleButton7.setText("7"); jToggleButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton7ActionPerformed(evt); } }); jToggleButton8.setText("8"); jToggleButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton8ActionPerformed(evt); } }); jToggleButton9.setText("9"); jToggleButton9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton9ActionPerformed(evt); } }); jToggleButton10.setText("0"); jToggleButton10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton10ActionPerformed(evt); } }); jToggleButton11.setText("."); jToggleButton11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton11ActionPerformed(evt); } }); jToggleButton12.setBackground(new java.awt.Color(153, 204, 255)); jToggleButton12.setText("="); jToggleButton12.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton12ActionPerformed(evt); } }); jToggleButton13.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton13.setText("/"); jToggleButton13.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton13ActionPerformed(evt); } }); jToggleButton14.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton14.setText("*"); jToggleButton14.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton14ActionPerformed(evt); } }); jToggleButton15.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton15.setText("+"); jToggleButton15.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton15ActionPerformed(evt); } }); jToggleButton16.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton16.setText("-"); jToggleButton16.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton16ActionPerformed(evt); } }); jToggleButton17.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton17.setText("^"); jToggleButton17.setToolTipText(""); jToggleButton17.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton17ActionPerformed(evt); } }); jToggleButton18.setBackground(new java.awt.Color(153, 204, 255)); jToggleButton18.setText("C"); jToggleButton18.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jToggleButton18.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton18ActionPerformed(evt); } }); jToggleButton19.setBackground(new java.awt.Color(153, 204, 255)); jToggleButton19.setText("CE"); jToggleButton19.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jToggleButton19.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton19ActionPerformed(evt); } }); jToggleButton20.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton20.setText("1/x"); jToggleButton20.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton20ActionPerformed(evt); } }); jToggleButton21.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton21.setText("^10"); jToggleButton21.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton21ActionPerformed(evt); } }); jToggleButton22.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton22.setText("log"); jToggleButton22.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton22ActionPerformed(evt); } }); jToggleButton23.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton23.setText("^e"); jToggleButton23.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton23ActionPerformed(evt); } }); jToggleButton24.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton24.setText("∛"); jToggleButton24.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton24ActionPerformed(evt); } }); jToggleButton25.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton25.setText("Sen"); jToggleButton25.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton25ActionPerformed(evt); } }); jToggleButton26.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton26.setText("Cos"); jToggleButton26.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton26ActionPerformed(evt); } }); jToggleButton27.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton27.setText("Tan"); jToggleButton27.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton27ActionPerformed(evt); } }); jToggleButton28.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton28.setText("Sen-1"); jToggleButton28.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton28ActionPerformed(evt); } }); jToggleButton29.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton29.setText("Cos-1"); jToggleButton29.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton29ActionPerformed(evt); } }); jToggleButton30.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton30.setText("Tan-1"); jToggleButton30.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton30ActionPerformed(evt); } }); jToggleButton31.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton31.setText("Σ "); jToggleButton31.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton31ActionPerformed(evt); } }); jToggleButton32.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton32.setText("∏"); jToggleButton32.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton32ActionPerformed(evt); } }); jToggleButton33.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton33.setText("√a+b"); jToggleButton33.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton33ActionPerformed(evt); } }); jToggleButton34.setBackground(new java.awt.Color(255, 255, 204)); jToggleButton34.setText("!"); jToggleButton34.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButton34ActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jToggleButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jToggleButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jToggleButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jToggleButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jToggleButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jToggleButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addComponent(jToggleButton19, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jToggleButton18, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jToggleButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jToggleButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jToggleButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jToggleButton17, javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE) .addComponent(jToggleButton15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton16, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jToggleButton22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToggleButton27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton26, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE) .addComponent(jToggleButton25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton31, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton33, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(5, 5, 5) .addComponent(jToggleButton28, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToggleButton29, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jToggleButton30, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToggleButton34, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToggleButton32, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jToggleButton13, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton18, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton19, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton20, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton25, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton28, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jToggleButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton21, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton26, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton29, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jToggleButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton22, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton27, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton30, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jToggleButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton23, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton31, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton32, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jToggleButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jToggleButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jToggleButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jToggleButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton17, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton24, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton33, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToggleButton34, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(88, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed setNumber("1"); }//GEN-LAST:event_jToggleButton1ActionPerformed private void jToggleButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton2ActionPerformed setNumber("2"); }//GEN-LAST:event_jToggleButton2ActionPerformed private void jToggleButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton3ActionPerformed setNumber("3"); }//GEN-LAST:event_jToggleButton3ActionPerformed private void jToggleButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton4ActionPerformed setNumber("4"); }//GEN-LAST:event_jToggleButton4ActionPerformed private void jToggleButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton5ActionPerformed setNumber("5"); }//GEN-LAST:event_jToggleButton5ActionPerformed private void jToggleButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton6ActionPerformed setNumber("6"); }//GEN-LAST:event_jToggleButton6ActionPerformed private void jToggleButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton7ActionPerformed setNumber("7"); }//GEN-LAST:event_jToggleButton7ActionPerformed private void jToggleButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton8ActionPerformed setNumber("8"); }//GEN-LAST:event_jToggleButton8ActionPerformed private void jToggleButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton9ActionPerformed setNumber("9"); }//GEN-LAST:event_jToggleButton9ActionPerformed private void jToggleButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton10ActionPerformed setNumber("0"); }//GEN-LAST:event_jToggleButton10ActionPerformed private void jToggleButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton11ActionPerformed if (jLabel1.getText().equals("")) { jLabel1.setText(jLabel1.getText() + "0."); } else { jLabel1.setText(jLabel1.getText() + "."); } }//GEN-LAST:event_jToggleButton11ActionPerformed private void jToggleButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton12ActionPerformed String resultado; numero2 = jLabel1.getText(); if (!numero2.equals("")) { resultado = calculadora(numero1, signo, numero2); jLabel1.setText(resultado); } }//GEN-LAST:event_jToggleButton12ActionPerformed private void jToggleButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton13ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); signo = "/"; jLabel1.setText(""); } }//GEN-LAST:event_jToggleButton13ActionPerformed private void jToggleButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton14ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); signo = "*"; jLabel1.setText(""); } }//GEN-LAST:event_jToggleButton14ActionPerformed private void jToggleButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton15ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); signo = "+"; jLabel1.setText(""); } }//GEN-LAST:event_jToggleButton15ActionPerformed private void jToggleButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton16ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); signo = "-"; jLabel1.setText(""); } }//GEN-LAST:event_jToggleButton16ActionPerformed private void jToggleButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton17ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); signo = "^"; jLabel1.setText(""); } }//GEN-LAST:event_jToggleButton17ActionPerformed private void jToggleButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton18ActionPerformed jLabel1.setText(""); numero1 = "0"; }//GEN-LAST:event_jToggleButton18ActionPerformed private void jToggleButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton19ActionPerformed String crh = jLabel1.getText(); if (!crh.equals("")) { int lengthAux = crh.length(); crh = crh.substring(0, lengthAux - 1); jLabel1.setText(crh); } }//GEN-LAST:event_jToggleButton19ActionPerformed private void jToggleButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton20ActionPerformed Double result; numero1 = jLabel1.getText(); if (!numero1.equals("")) { result = Math.pow(Double.parseDouble(numero1), -1); jLabel1.setText(result.toString()); } }//GEN-LAST:event_jToggleButton20ActionPerformed private void jToggleButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton21ActionPerformed Double result; numero1 = jLabel1.getText(); if (!numero1.equals("")) { result = Math.pow(10, Double.parseDouble(numero1)); jLabel1.setText(result.toString()); } }//GEN-LAST:event_jToggleButton21ActionPerformed private void jToggleButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton22ActionPerformed Double result; numero1 = jLabel1.getText(); if (!numero1.equals("")) { result = Math.log10(Double.parseDouble(numero1)); jLabel1.setText(result.toString()); } }//GEN-LAST:event_jToggleButton22ActionPerformed private void jToggleButton23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton23ActionPerformed Double result; Double e = Math.E; numero1 = jLabel1.getText(); if (!numero1.equals("")) { result = Math.pow(e, Double.parseDouble(numero1)); jLabel1.setText(result.toString()); } }//GEN-LAST:event_jToggleButton23ActionPerformed private void jToggleButton24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton24ActionPerformed Double result; Double i; i = (1.0 / 3.0); numero1 = jLabel1.getText(); if (!numero1.equals("")) { result = Math.pow(Double.parseDouble(numero1), i); jLabel1.setText(result.toString()); } }//GEN-LAST:event_jToggleButton24ActionPerformed private void jToggleButton25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton25ActionPerformed signo = "Sen("; String resultado; numero1 = jLabel1.getText(); if (!numero1.equals("")) { resultado = trigonometria(numero1, signo); jLabel1.setText(resultado + " radianes"); } }//GEN-LAST:event_jToggleButton25ActionPerformed private void jToggleButton26ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton26ActionPerformed signo = "Cos("; String resultado; numero1 = jLabel1.getText(); if (!numero1.equals("")) { resultado = trigonometria(numero1, signo); jLabel1.setText(resultado + " radianes"); } }//GEN-LAST:event_jToggleButton26ActionPerformed private void jToggleButton27ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton27ActionPerformed signo = "Tan("; String resultado; numero1 = jLabel1.getText(); if (!numero1.equals("")) { resultado = trigonometria(numero1, signo); jLabel1.setText(resultado + " radianes"); } }//GEN-LAST:event_jToggleButton27ActionPerformed private void jToggleButton28ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton28ActionPerformed signo = "ArcSen("; String resultado; numero1 = jLabel1.getText(); if (!numero1.equals("")) { resultado = trigonometria(numero1, signo); jLabel1.setText(resultado + " radianes"); } }//GEN-LAST:event_jToggleButton28ActionPerformed private void jToggleButton29ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton29ActionPerformed signo = "ArcCos("; String resultado; numero1 = jLabel1.getText(); if (!numero1.equals("")) { resultado = trigonometria(numero1, signo); jLabel1.setText(resultado + " radianes"); } }//GEN-LAST:event_jToggleButton29ActionPerformed private void jToggleButton30ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton30ActionPerformed signo = "ArcTan("; String resultado; numero1 = jLabel1.getText(); if (!numero1.equals("")) { resultado = trigonometria(numero1, signo); jLabel1.setText(resultado + " radianes"); } }//GEN-LAST:event_jToggleButton30ActionPerformed private void jToggleButton31ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton31ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); signo = "Σ"; jLabel1.setText(""); } }//GEN-LAST:event_jToggleButton31ActionPerformed private void jToggleButton32ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton32ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); signo = "∏"; jLabel1.setText(""); } }//GEN-LAST:event_jToggleButton32ActionPerformed private void jToggleButton33ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton33ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); signo = "√a+b"; jLabel1.setText(""); } }//GEN-LAST:event_jToggleButton33ActionPerformed private void jToggleButton34ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton34ActionPerformed if (!jLabel1.getText().equals("")) { numero1 = jLabel1.getText(); double value = Double.parseDouble(numero1); String result = String.valueOf(factorial(value)); jLabel1.setText(result); } }//GEN-LAST:event_jToggleButton34ActionPerformed public static String calculadora(String numero1, String signo, String numero2) { Double resultado = 0.0; String respuesta; if (signo.equals("-")) { resultado = Double.parseDouble(numero1) - Double.parseDouble(numero2); } else if (signo.equals("+")) { resultado = Double.parseDouble(numero1) + Double.parseDouble(numero2); } else if (signo.equals("*")) { resultado = Double.parseDouble(numero1) * Double.parseDouble(numero2); } else if (signo.equals("/")) { resultado = Double.parseDouble(numero1) / Double.parseDouble(numero2); } else if (signo.equals("^")) { resultado = Math.pow(Double.parseDouble(numero1), Double.parseDouble(numero2)); } else if (signo.equals("Σ")) { Double i = 0.0; if (!numero2.equals("")) { int inicio = Integer.parseInt(numero1); int limite = Integer.parseInt(numero2); for (int e = inicio; e <= limite; e++) { i += e; } resultado = i; } } else if (signo.equals("∏")) { Double i = 1.0; if (!numero2.equals("")) { int inicio = Integer.parseInt(numero1); int limite = Integer.parseInt(numero2); for (int e = inicio; e <= limite; e++) { i *= e; } resultado = i; } } else if (signo.equals("√a+b")) { if (!numero2.equals("")) { double potenciaA, potenciaB; int a = Integer.parseInt(numero1); int b = Integer.parseInt(numero2); potenciaA = Math.pow(a, 2); potenciaB = Math.pow(b, 2); double sumaPotencia = potenciaA + potenciaB; resultado = Math.sqrt(sumaPotencia); } } else { System.out.println("Operador no reconocido"); } respuesta = resultado.toString(); return respuesta; } public static String trigonometria(String numero1, String signo) { Double resul = 0.0; String respuesta; double cos, tan, sen, num; if (signo.equals("Cos(")) { cos = Double.parseDouble(numero1); cos = Math.cos(cos); resul = redondear(cos); } if (signo.equals("Sen(")) { sen = Double.parseDouble(numero1); sen = Math.sin(sen); resul = redondear(sen); } if (signo.equals("Tan(")) { tan = Double.parseDouble(numero1); tan = Math.tan(tan); resul = redondear(tan); } if (signo.equals("ArcCos(")) { double arcCos = Double.parseDouble(numero1); arcCos = Math.acos(arcCos); resul = redondear(arcCos); } if (signo.equals("ArcSen(")) { double arcSen = Double.parseDouble(numero1); arcSen = Math.asin(arcSen); resul = redondear(arcSen); } if (signo.equals("ArcTan(")) { double arcTan = Double.parseDouble(numero1); arcTan = Math.atan(arcTan); resul = redondear(arcTan); } if (signo.equals("+/-")) { num = Double.parseDouble(numero1); resul = (-1) * num; } respuesta = resul.toString(); return respuesta; } private void setNumber(String numero) { jLabel1.setText(jLabel1.getText() + numero); } public static double redondear(double valor) { valor = valor * 100; valor = Math.round(valor); valor = valor / 100; return valor; } public static double factorial(double numberFact) { if (numberFact <= 1) { return 1; } return numberFact * factorial(numberFact - 1); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JToggleButton jToggleButton1; private javax.swing.JToggleButton jToggleButton10; private javax.swing.JToggleButton jToggleButton11; private javax.swing.JToggleButton jToggleButton12; private javax.swing.JToggleButton jToggleButton13; private javax.swing.JToggleButton jToggleButton14; private javax.swing.JToggleButton jToggleButton15; private javax.swing.JToggleButton jToggleButton16; private javax.swing.JToggleButton jToggleButton17; private javax.swing.JToggleButton jToggleButton18; private javax.swing.JToggleButton jToggleButton19; private javax.swing.JToggleButton jToggleButton2; private javax.swing.JToggleButton jToggleButton20; private javax.swing.JToggleButton jToggleButton21; private javax.swing.JToggleButton jToggleButton22; private javax.swing.JToggleButton jToggleButton23; private javax.swing.JToggleButton jToggleButton24; private javax.swing.JToggleButton jToggleButton25; private javax.swing.JToggleButton jToggleButton26; private javax.swing.JToggleButton jToggleButton27; private javax.swing.JToggleButton jToggleButton28; private javax.swing.JToggleButton jToggleButton29; private javax.swing.JToggleButton jToggleButton3; private javax.swing.JToggleButton jToggleButton30; private javax.swing.JToggleButton jToggleButton31; private javax.swing.JToggleButton jToggleButton32; private javax.swing.JToggleButton jToggleButton33; private javax.swing.JToggleButton jToggleButton34; private javax.swing.JToggleButton jToggleButton4; private javax.swing.JToggleButton jToggleButton5; private javax.swing.JToggleButton jToggleButton6; private javax.swing.JToggleButton jToggleButton7; private javax.swing.JToggleButton jToggleButton8; private javax.swing.JToggleButton jToggleButton9; // End of variables declaration//GEN-END:variables }
Leave a Comment