Boa Noite. eu estou com um erro na minha calculadora já tentei de tudo mais não sei por que ela não calcula quem poder ajudar eu agradeço.
Codigo:
package Interface;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class Calculadora extends javax.swing.JFrame {
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine se = sem.getEngineByName("JavaScript");
public Calculadora() {
initComponents();
setLocationRelativeTo(null);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
txtOperacoes = new javax.swing.JLabel();
txtResultado = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
btnIgual = new javax.swing.JButton();
btnNove = new javax.swing.JButton();
btnPotencia = new javax.swing.JButton();
btnPorcentagem = new javax.swing.JButton();
btnDivisao = new javax.swing.JButton();
btnMutiplicacao = new javax.swing.JButton();
btnMenos = new javax.swing.JButton();
btnMais = new javax.swing.JButton();
btnApagar = new javax.swing.JButton();
btnSete = new javax.swing.JButton();
btnOito = new javax.swing.JButton();
btnQuatro = new javax.swing.JButton();
btnCinco = new javax.swing.JButton();
btnSeis = new javax.swing.JButton();
btnUm = new javax.swing.JButton();
btnDois = new javax.swing.JButton();
btnTres = new javax.swing.JButton();
btnZero = new javax.swing.JButton();
btnPonto = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel1.setBackground(new java.awt.Color(244, 253, 251));
jPanel1.setForeground(new java.awt.Color(244, 253, 251));
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
txtOperacoes.setFont(new java.awt.Font("Roboto", 1, 18)); // NOI18N
txtOperacoes.setForeground(new java.awt.Color(55, 62, 71));
txtOperacoes.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jPanel1.add(txtOperacoes, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, 310, 40));
txtResultado.setFont(new java.awt.Font("Roboto Light", 1, 48)); // NOI18N
txtResultado.setForeground(new java.awt.Color(55, 62, 71));
txtResultado.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jPanel1.add(txtResultado, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, 310, 59));
getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 330, 160));
jPanel2.setBackground(new java.awt.Color(255, 255, 255));
jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
btnIgual.setFont(new java.awt.Font("Roboto", 0, 30)); // NOI18N
btnIgual.setForeground(new java.awt.Color(255, 255, 255));
btnIgual.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn3.png"))); // NOI18N
btnIgual.setText("=");
btnIgual.setFocusPainted(false);
btnIgual.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnIgual.setPreferredSize(new java.awt.Dimension(50, 50));
btnIgual.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn3.png"))); // NOI18N
btnIgual.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn3_press.png"))); // NOI18N
btnIgual.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnIgualActionPerformed(evt);
}
});
jPanel2.add(btnIgual, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 340, -1, -1));
btnNove.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnNove.setForeground(new java.awt.Color(55, 62, 71));
btnNove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnNove.setText("9");
btnNove.setFocusPainted(false);
btnNove.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnNove.setMaximumSize(new java.awt.Dimension(20, 20));
btnNove.setMinimumSize(new java.awt.Dimension(20, 20));
btnNove.setPreferredSize(new java.awt.Dimension(50, 50));
btnNove.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnNove.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnNove.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNoveActionPerformed(evt);
}
});
jPanel2.add(btnNove, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 100, -1, -1));
btnPotencia.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnPotencia.setForeground(new java.awt.Color(55, 62, 71));
btnPotencia.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnPotencia.setText("^");
btnPotencia.setFocusPainted(false);
btnPotencia.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnPotencia.setMaximumSize(new java.awt.Dimension(100, 20));
btnPotencia.setMinimumSize(new java.awt.Dimension(100, 20));
btnPotencia.setPreferredSize(new java.awt.Dimension(50, 50));
btnPotencia.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnPotencia.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnPotencia.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPotenciaActionPerformed(evt);
}
});
jPanel2.add(btnPotencia, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 20, -1, -1));
btnPorcentagem.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnPorcentagem.setForeground(new java.awt.Color(55, 62, 71));
btnPorcentagem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnPorcentagem.setText("%");
btnPorcentagem.setFocusPainted(false);
btnPorcentagem.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnPorcentagem.setPreferredSize(new java.awt.Dimension(50, 50));
btnPorcentagem.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnPorcentagem.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnPorcentagem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPorcentagemActionPerformed(evt);
}
});
jPanel2.add(btnPorcentagem, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 20, -1, -1));
btnDivisao.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnDivisao.setForeground(new java.awt.Color(55, 62, 71));
btnDivisao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnDivisao.setText("÷");
btnDivisao.setFocusPainted(false);
btnDivisao.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnDivisao.setPreferredSize(new java.awt.Dimension(50, 50));
btnDivisao.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnDivisao.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnDivisao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDivisaoActionPerformed(evt);
}
});
jPanel2.add(btnDivisao, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 20, -1, -1));
btnMutiplicacao.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnMutiplicacao.setForeground(new java.awt.Color(55, 62, 71));
btnMutiplicacao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnMutiplicacao.setText("x");
btnMutiplicacao.setFocusPainted(false);
btnMutiplicacao.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnMutiplicacao.setPreferredSize(new java.awt.Dimension(50, 50));
btnMutiplicacao.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnMutiplicacao.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnMutiplicacao.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMutiplicacaoActionPerformed(evt);
}
});
jPanel2.add(btnMutiplicacao, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 100, -1, -1));
btnMenos.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnMenos.setForeground(new java.awt.Color(55, 62, 71));
btnMenos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnMenos.setText("-");
btnMenos.setFocusPainted(false);
btnMenos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnMenos.setPreferredSize(new java.awt.Dimension(50, 50));
btnMenos.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnMenos.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnMenos.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMenosActionPerformed(evt);
}
});
jPanel2.add(btnMenos, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 180, -1, -1));
btnMais.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnMais.setForeground(new java.awt.Color(55, 62, 71));
btnMais.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnMais.setText("+");
btnMais.setFocusPainted(false);
btnMais.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnMais.setPreferredSize(new java.awt.Dimension(50, 50));
btnMais.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnMais.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnMais.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMaisActionPerformed(evt);
}
});
jPanel2.add(btnMais, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 260, -1, -1));
btnApagar.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnApagar.setForeground(new java.awt.Color(55, 62, 71));
btnApagar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnApagar.setText("C");
btnApagar.setFocusPainted(false);
btnApagar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnApagar.setMaximumSize(new java.awt.Dimension(20, 20));
btnApagar.setMinimumSize(new java.awt.Dimension(20, 20));
btnApagar.setPreferredSize(new java.awt.Dimension(50, 50));
btnApagar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnApagar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnApagar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnApagarActionPerformed(evt);
}
});
jPanel2.add(btnApagar, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, -1, -1));
btnSete.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnSete.setForeground(new java.awt.Color(55, 62, 71));
btnSete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnSete.setText("7");
btnSete.setFocusPainted(false);
btnSete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnSete.setMaximumSize(new java.awt.Dimension(20, 20));
btnSete.setMinimumSize(new java.awt.Dimension(20, 20));
btnSete.setPreferredSize(new java.awt.Dimension(50, 50));
btnSete.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnSete.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnSete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSeteActionPerformed(evt);
}
});
jPanel2.add(btnSete, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, -1, -1));
btnOito.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnOito.setForeground(new java.awt.Color(55, 62, 71));
btnOito.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnOito.setText("8");
btnOito.setFocusPainted(false);
btnOito.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnOito.setMaximumSize(new java.awt.Dimension(20, 20));
btnOito.setMinimumSize(new java.awt.Dimension(20, 20));
btnOito.setPreferredSize(new java.awt.Dimension(50, 50));
btnOito.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnOito.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnOito.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOitoActionPerformed(evt);
}
});
jPanel2.add(btnOito, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 100, -1, -1));
btnQuatro.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnQuatro.setForeground(new java.awt.Color(55, 62, 71));
btnQuatro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnQuatro.setText("4");
btnQuatro.setFocusPainted(false);
btnQuatro.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnQuatro.setMaximumSize(new java.awt.Dimension(20, 20));
btnQuatro.setMinimumSize(new java.awt.Dimension(20, 20));
btnQuatro.setPreferredSize(new java.awt.Dimension(50, 50));
btnQuatro.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnQuatro.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnQuatro.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnQuatroActionPerformed(evt);
}
});
jPanel2.add(btnQuatro, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 180, -1, -1));
btnCinco.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnCinco.setForeground(new java.awt.Color(55, 62, 71));
btnCinco.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnCinco.setText("5");
btnCinco.setFocusPainted(false);
btnCinco.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnCinco.setMaximumSize(new java.awt.Dimension(20, 20));
btnCinco.setMinimumSize(new java.awt.Dimension(20, 20));
btnCinco.setPreferredSize(new java.awt.Dimension(50, 50));
btnCinco.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnCinco.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnCinco.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCincoActionPerformed(evt);
}
});
jPanel2.add(btnCinco, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 180, -1, -1));
btnSeis.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnSeis.setForeground(new java.awt.Color(55, 62, 71));
btnSeis.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnSeis.setText("6");
btnSeis.setFocusPainted(false);
btnSeis.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnSeis.setMaximumSize(new java.awt.Dimension(20, 20));
btnSeis.setMinimumSize(new java.awt.Dimension(20, 20));
btnSeis.setPreferredSize(new java.awt.Dimension(50, 50));
btnSeis.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnSeis.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnSeis.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSeisActionPerformed(evt);
}
});
jPanel2.add(btnSeis, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 180, -1, -1));
btnUm.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnUm.setForeground(new java.awt.Color(55, 62, 71));
btnUm.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnUm.setText("1");
btnUm.setFocusPainted(false);
btnUm.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnUm.setMaximumSize(new java.awt.Dimension(20, 20));
btnUm.setMinimumSize(new java.awt.Dimension(20, 20));
btnUm.setPreferredSize(new java.awt.Dimension(50, 50));
btnUm.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnUm.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnUm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnUmActionPerformed(evt);
}
});
jPanel2.add(btnUm, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 260, -1, -1));
btnDois.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnDois.setForeground(new java.awt.Color(55, 62, 71));
btnDois.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnDois.setText("2");
btnDois.setFocusPainted(false);
btnDois.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnDois.setMaximumSize(new java.awt.Dimension(20, 20));
btnDois.setMinimumSize(new java.awt.Dimension(20, 20));
btnDois.setPreferredSize(new java.awt.Dimension(50, 50));
btnDois.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnDois.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnDois.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDoisActionPerformed(evt);
}
});
jPanel2.add(btnDois, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 260, -1, -1));
btnTres.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnTres.setForeground(new java.awt.Color(55, 62, 71));
btnTres.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnTres.setText("3");
btnTres.setFocusPainted(false);
btnTres.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnTres.setMaximumSize(new java.awt.Dimension(20, 20));
btnTres.setMinimumSize(new java.awt.Dimension(20, 20));
btnTres.setPreferredSize(new java.awt.Dimension(50, 50));
btnTres.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnTres.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnTres.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnTresActionPerformed(evt);
}
});
jPanel2.add(btnTres, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 260, -1, -1));
btnZero.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnZero.setForeground(new java.awt.Color(55, 62, 71));
btnZero.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnZero.setText("0");
btnZero.setFocusPainted(false);
btnZero.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnZero.setMaximumSize(new java.awt.Dimension(20, 20));
btnZero.setMinimumSize(new java.awt.Dimension(20, 20));
btnZero.setPreferredSize(new java.awt.Dimension(50, 50));
btnZero.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnZero.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnZero.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnZeroActionPerformed(evt);
}
});
jPanel2.add(btnZero, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 340, -1, -1));
btnPonto.setFont(new java.awt.Font("Roboto Light", 0, 24)); // NOI18N
btnPonto.setForeground(new java.awt.Color(55, 62, 71));
btnPonto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn2.png"))); // NOI18N
btnPonto.setText(".");
btnPonto.setFocusPainted(false);
btnPonto.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnPonto.setMaximumSize(new java.awt.Dimension(20, 20));
btnPonto.setMinimumSize(new java.awt.Dimension(20, 20));
btnPonto.setPreferredSize(new java.awt.Dimension(50, 50));
btnPonto.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1.png"))); // NOI18N
btnPonto.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/imagens/btn1_press.png"))); // NOI18N
btnPonto.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPontoActionPerformed(evt);
}
});
jPanel2.add(btnPonto, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 340, -1, -1));
getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 160, 330, 400));
pack();
}// </editor-fold>
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Calculadora.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Calculadora().setVisible(true);
}
});
}
public void addNumero(String digito){
txtOperacoes.setText(txtOperacoes.getText()+digito);
}
private void btnIgualActionPerformed(java.awt.event.ActionEvent evt) {
É aqui que tento fazer a operação
try{
String resultado = se.eval(txtOperacoes.getText()).toString();
txtResultado.setText(resultado);
} catch(Exception e){
txtOperacoes.setText(“ERRO”);
}
}
private void btnNoveActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("9");
btnIgual.doClick();
}
private void btnDivisaoActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("/");
}
private void btnMutiplicacaoActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("*");
}
private void btnMenosActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("-");
}
private void btnMaisActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("+");
}
private void btnApagarActionPerformed(java.awt.event.ActionEvent evt) {
txtOperacoes.setText("");
txtResultado.setText("");
}
private void btnSeteActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("7");
btnIgual.doClick();
}
private void btnOitoActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("8");
btnIgual.doClick();
}
private void btnQuatroActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("4");
btnIgual.doClick();
}
private void btnCincoActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("5");
btnIgual.doClick();
}
private void btnSeisActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("6");
btnIgual.doClick();
}
private void btnUmActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("1");
btnIgual.doClick();
}
private void btnDoisActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("2");
btnIgual.doClick();
}
private void btnTresActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("3");
btnIgual.doClick();
}
private void btnZeroActionPerformed(java.awt.event.ActionEvent evt) {
addNumero("0");
btnIgual.doClick();
}
// Variables declaration - do not modify
private javax.swing.JButton btnApagar;
private javax.swing.JButton btnCinco;
private javax.swing.JButton btnDivisao;
private javax.swing.JButton btnDois;
private javax.swing.JButton btnIgual;
private javax.swing.JButton btnMais;
private javax.swing.JButton btnMenos;
private javax.swing.JButton btnMutiplicacao;
private javax.swing.JButton btnNove;
private javax.swing.JButton btnOito;
private javax.swing.JButton btnPonto;
private javax.swing.JButton btnPorcentagem;
private javax.swing.JButton btnPotencia;
private javax.swing.JButton btnQuatro;
private javax.swing.JButton btnSeis;
private javax.swing.JButton btnSete;
private javax.swing.JButton btnTres;
private javax.swing.JButton btnUm;
private javax.swing.JButton btnZero;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel txtOperacoes;
private javax.swing.JLabel txtResultado;
// End of variables declaration
}
Imagem