Calculadora no NetBeans

0 respostas
pmpvieira

Estou a fazer uma calculadora no NetBeans e já fiz uma série de butões mas o botão da soma, subtracção, multiplicação e divisão não funcionam direito… Se pudessem dar uma olhada ao programa para ver o que estará mal agradecia muito. Desde já um grande obrigado a todos

package calc;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 * The application's main frame.
 */
public class CalcView extends FrameView {

    double M1=0;
    int op=0;
    
    public CalcView(SingleFrameApplication app) {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = CalcApp.getApplication().getMainFrame();
            aboutBox = new CalcAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        CalcApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor 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() {

        mainPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        B1 = new javax.swing.JButton();
        B4 = new javax.swing.JButton();
        B2 = new javax.swing.JButton();
        B3 = new javax.swing.JButton();
        B5 = new javax.swing.JButton();
        B6 = new javax.swing.JButton();
        B7 = new javax.swing.JButton();
        B8 = new javax.swing.JButton();
        B9 = new javax.swing.JButton();
        Bsoma = new javax.swing.JButton();
        Bsub = new javax.swing.JButton();
        Bmult = new javax.swing.JButton();
        Bdiv = new javax.swing.JButton();
        Bexe = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        B0 = new javax.swing.JButton();
        Bponto = new javax.swing.JButton();
        Jfield = new javax.swing.JFormattedTextField();
        Bpi = new javax.swing.JButton();
        BC = new javax.swing.JButton();
        Bsqrt = new javax.swing.JButton();
        Bpow2 = new javax.swing.JButton();
        Bpower = new javax.swing.JButton();
        Be = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        Blog = new javax.swing.JButton();
        Bln = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jToolBar1 = new javax.swing.JToolBar();

        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(calc.CalcApp.class).getContext().getResourceMap(CalcView.class);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        mainPanel.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        B1.setText(resourceMap.getString("B1.text")); // NOI18N
        B1.setName("B1"); // NOI18N
        B1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B1ActionPerformed(evt);
            }
        });
        mainPanel.add(B1, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 130, -1, -1));

        B4.setText(resourceMap.getString("B4.text")); // NOI18N
        B4.setName("B4"); // NOI18N
        B4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B4ActionPerformed(evt);
            }
        });
        mainPanel.add(B4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 170, -1, -1));

        B2.setText(resourceMap.getString("B2.text")); // NOI18N
        B2.setName("B2"); // NOI18N
        B2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B2ActionPerformed(evt);
            }
        });
        mainPanel.add(B2, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 130, -1, -1));

        B3.setText(resourceMap.getString("B3.text")); // NOI18N
        B3.setName("B3"); // NOI18N
        B3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B3ActionPerformed(evt);
            }
        });
        mainPanel.add(B3, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 130, -1, -1));

        B5.setText(resourceMap.getString("B5.text")); // NOI18N
        B5.setName("B5"); // NOI18N
        B5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B5ActionPerformed(evt);
            }
        });
        mainPanel.add(B5, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 170, -1, -1));

        B6.setText(resourceMap.getString("B6.text")); // NOI18N
        B6.setName("B6"); // NOI18N
        B6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B6ActionPerformed(evt);
            }
        });
        mainPanel.add(B6, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 170, -1, -1));

        B7.setText(resourceMap.getString("B7.text")); // NOI18N
        B7.setName("B7"); // NOI18N
        B7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B7ActionPerformed(evt);
            }
        });
        mainPanel.add(B7, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 210, -1, -1));

        B8.setText(resourceMap.getString("B8.text")); // NOI18N
        B8.setName("B8"); // NOI18N
        B8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B8ActionPerformed(evt);
            }
        });
        mainPanel.add(B8, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 210, -1, -1));

        B9.setText(resourceMap.getString("B9.text")); // NOI18N
        B9.setName("B9"); // NOI18N
        B9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B9ActionPerformed(evt);
            }
        });
        mainPanel.add(B9, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 210, -1, -1));

        Bsoma.setText(resourceMap.getString("Bsoma.text")); // NOI18N
        Bsoma.setName("Bsoma"); // NOI18N
        Bsoma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BsomaActionPerformed(evt);
            }
        });
        mainPanel.add(Bsoma, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 120, -1, -1));

        Bsub.setText(resourceMap.getString("Bsub.text")); // NOI18N
        Bsub.setName("Bsub"); // NOI18N
        Bsub.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BsubActionPerformed(evt);
            }
        });
        mainPanel.add(Bsub, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 120, -1, -1));

        Bmult.setText(resourceMap.getString("Bmult.text")); // NOI18N
        Bmult.setName("Bmult"); // NOI18N
        Bmult.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BmultActionPerformed(evt);
            }
        });
        mainPanel.add(Bmult, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 160, -1, -1));

        Bdiv.setText(resourceMap.getString("Bdiv.text")); // NOI18N
        Bdiv.setName("Bdiv"); // NOI18N
        Bdiv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BdivActionPerformed(evt);
            }
        });
        mainPanel.add(Bdiv, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 160, -1, -1));

        Bexe.setText(resourceMap.getString("Bexe.text")); // NOI18N
        Bexe.setName("Bexe"); // NOI18N
        Bexe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BexeActionPerformed(evt);
            }
        });
        mainPanel.add(Bexe, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 240, 60, 30));

        jSeparator1.setName("jSeparator1"); // NOI18N
        mainPanel.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        B0.setText(resourceMap.getString("B0.text")); // NOI18N
        B0.setName("B0"); // NOI18N
        B0.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                B0ActionPerformed(evt);
            }
        });
        mainPanel.add(B0, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 250, -1, -1));

        Bponto.setText(resourceMap.getString("Bponto.text")); // NOI18N
        Bponto.setName("Bponto"); // NOI18N
        Bponto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BpontoActionPerformed(evt);
            }
        });
        mainPanel.add(Bponto, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 250, -1, -1));

        Jfield.setText(resourceMap.getString("Jfield.text")); // NOI18N
        Jfield.setName("Jfield"); // NOI18N
        mainPanel.add(Jfield, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 40, 180, 30));

        Bpi.setText(resourceMap.getString("Bpi.text")); // NOI18N
        Bpi.setName("Bpi"); // NOI18N
        Bpi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BpiActionPerformed(evt);
            }
        });
        mainPanel.add(Bpi, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 200, -1, -1));

        BC.setText(resourceMap.getString("BC.text")); // NOI18N
        BC.setName("BC"); // NOI18N
        BC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BCActionPerformed(evt);
            }
        });
        mainPanel.add(BC, new org.netbeans.lib.awtextra.AbsoluteConstraints(309, 240, 40, 30));

        Bsqrt.setText(resourceMap.getString("Bsqrt.text")); // NOI18N
        Bsqrt.setName("Bsqrt"); // NOI18N
        Bsqrt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BsqrtActionPerformed(evt);
            }
        });
        mainPanel.add(Bsqrt, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 180, -1, -1));

        Bpow2.setText(resourceMap.getString("Bpow2.text")); // NOI18N
        Bpow2.setName("Bpow2"); // NOI18N
        Bpow2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Bpow2ActionPerformed(evt);
            }
        });
        mainPanel.add(Bpow2, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 120, -1, -1));

        Bpower.setText(resourceMap.getString("Bpower.text")); // NOI18N
        Bpower.setName("Bpower"); // NOI18N
        Bpower.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BpowerActionPerformed(evt);
            }
        });
        mainPanel.add(Bpower, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 150, -1, -1));

        Be.setText(resourceMap.getString("Be.text")); // NOI18N
        Be.setName("Be"); // NOI18N
        Be.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BeActionPerformed(evt);
            }
        });
        mainPanel.add(Be, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 200, -1, -1));

        jSeparator2.setName("jSeparator2"); // NOI18N
        mainPanel.add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 90, 500, 10));

        jSeparator3.setName("jSeparator3"); // NOI18N
        mainPanel.add(jSeparator3, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 292, 110, 0));

        Blog.setText(resourceMap.getString("Blog.text")); // NOI18N
        Blog.setName("Blog"); // NOI18N
        Blog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BlogActionPerformed(evt);
            }
        });
        mainPanel.add(Blog, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 150, -1, -1));

        Bln.setText(resourceMap.getString("Bln.text")); // NOI18N
        Bln.setName("Bln"); // NOI18N
        Bln.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BlnActionPerformed(evt);
            }
        });
        mainPanel.add(Bln, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 120, -1, -1));

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(calc.CalcApp.class).getContext().getActionMap(CalcView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 332, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        );

        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>

private void B1ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
Jfield.setText(Jfield.getText()+1);                                  
}

private void B2ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
Jfield.setText(Jfield.getText()+2);
}                                  

private void B3ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+3);
}                                  

private void B4ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+4);
}                                  

private void B5ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+5);
}                                  

private void B6ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+6);
}                                  

private void B7ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+7);
}                                  

private void B8ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+ 8);
}                                  

private void B9ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+9);
}                                  

private void B0ActionPerformed(java.awt.event.ActionEvent evt) {                                   
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+0);
}                                  

private void BpontoActionPerformed(java.awt.event.ActionEvent evt) {                                       
// TODO add your handling code here:
    Jfield.setText(Jfield.getText()+".");
}                                      

private void BsomaActionPerformed(java.awt.event.ActionEvent evt) {                                      
// TODO add your handling code here:
    op=1; //o 1 equivale à soma
    M1=Double.valueOf(Jfield.getText()).doubleValue();
    Jfield.setText("");
}                                     

private void BsubActionPerformed(java.awt.event.ActionEvent evt) {                                     
    op=2;
    M1=Double.valueOf(Jfield.getText()).doubleValue();
    Jfield.setText("");
}                                    

private void BmultActionPerformed(java.awt.event.ActionEvent evt) {                                      
    op=3;
    M1=Double.valueOf(Jfield.getText()).doubleValue();
    Jfield.setText("");
}                                     

private void BdivActionPerformed(java.awt.event.ActionEvent evt) {                                     
    op=4;
    M1=Double.valueOf(Jfield.getText()).doubleValue();
    Jfield.setText("");
}                                    

private void BexeActionPerformed(java.awt.event.ActionEvent evt) {                                          
switch (op) {
    case 1: Jfield.setText(String.valueOf(M1+Double.valueOf(Jfield.getText()).doubleValue()));
    case 2: Jfield.setText(String.valueOf(M1-Double.valueOf(Jfield.getText()).doubleValue()));
    case 3: Jfield.setText(String.valueOf(M1*Double.valueOf(Jfield.getText()).doubleValue()));
    case 4: Jfield.setText(String.valueOf(M1/Double.valueOf(Jfield.getText()).doubleValue()));
    case 5: Jfield.setText(String.valueOf(Math.pow(M1,Double.valueOf(Jfield.getText()))));
    
}
}

private void BsqrtActionPerformed(java.awt.event.ActionEvent evt) {
    Jfield.setText(String.valueOf(Math.sqrt(Double.valueOf(Jfield.getText()).doubleValue())));
}

private void BCActionPerformed(java.awt.event.ActionEvent evt) {
    Jfield.setText("");
    op=0;
}

private void BpiActionPerformed(java.awt.event.ActionEvent evt) {
    Jfield.setText(String.valueOf(Math.PI));
}

private void BeActionPerformed(java.awt.event.ActionEvent evt) {
    Jfield.setText(String.valueOf(Math.E));
}

private void Bpow2ActionPerformed(java.awt.event.ActionEvent evt) {
    Jfield.setText(String.valueOf(Math.pow(Double.valueOf(Jfield.getText()).doubleValue(),2)));
}

private void BpowerActionPerformed(java.awt.event.ActionEvent evt) {
    op=5;
    M1=Double.valueOf(Jfield.getText()).doubleValue();
    Jfield.setText("");
}

private void BlnActionPerformed(java.awt.event.ActionEvent evt) {
    Jfield.setText(String.valueOf(Math.log(Double.valueOf(Jfield.getText()).doubleValue())));
}

private void BlogActionPerformed(java.awt.event.ActionEvent evt) {
    Jfield.setText(String.valueOf(Math.log10(Double.valueOf(Jfield.getText()).doubleValue())));
}


    // Variables declaration - do not modify
    private javax.swing.JButton B0;
    private javax.swing.JButton B1;
    private javax.swing.JButton B2;
    private javax.swing.JButton B3;
    private javax.swing.JButton B4;
    private javax.swing.JButton B5;
    private javax.swing.JButton B6;
    private javax.swing.JButton B7;
    private javax.swing.JButton B8;
    private javax.swing.JButton B9;
    private javax.swing.JButton BC;
    private javax.swing.JButton Bdiv;
    private javax.swing.JButton Be;
    private javax.swing.JButton Bexe;
    private javax.swing.JButton Bln;
    private javax.swing.JButton Blog;
    private javax.swing.JButton Bmult;
    private javax.swing.JButton Bpi;
    private javax.swing.JButton Bponto;
    private javax.swing.JButton Bpow2;
    private javax.swing.JButton Bpower;
    private javax.swing.JButton Bsoma;
    private javax.swing.JButton Bsqrt;
    private javax.swing.JButton Bsub;
    private javax.swing.JFormattedTextField Jfield;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
}
Criado 28 de outubro de 2008
Respostas 0
Participantes 1