Preciso de ajudas em uma calculadora, a desenvolvi toda no netbeans e consegui configurar as opções basicas tipo: “±/*”, mas existem algumas coisas que não consegui como potencia de 2, raiz quadrada, e também queria uma função tipo rolinho de papel igual as de mesa e a função de impressão se alguem puder me ajudar com os código java desde ja obrigado pois estou iniciando em java ainda!
[code]package calculadora;
import java.awt.Toolkit;
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 java.text.NumberFormat;
import java.util.Locale;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
/**
-
The application’s main frame.
*/
public class CalculadoraView extends FrameView {/**
*-
@param app
*/
public CalculadoraView(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
/** 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”)
//
private void initComponents() {mainPanel = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
Total = new javax.swing.JTextPane();
jScrollPane2 = new javax.swing.JScrollPane();
Visor = new javax.swing.JTextPane();
Bt_Clear = new javax.swing.JButton();
Bt_Print = new javax.swing.JButton();
Bt_Backspace = new javax.swing.JButton();
Bt_7 = new javax.swing.JButton();
Bt_8 = new javax.swing.JButton();
Bt_Div = new javax.swing.JButton();
Bt_9 = new javax.swing.JButton();
Bt_4 = new javax.swing.JButton();
Bt_5 = new javax.swing.JButton();
Bt_6 = new javax.swing.JButton();
Bt_Mult = new javax.swing.JButton();
Bt_1 = new javax.swing.JButton();
Bt_3 = new javax.swing.JButton();
Bt_2 = new javax.swing.JButton();
Bt_Sub = new javax.swing.JButton();
Bt_0 = new javax.swing.JButton();
Bt_ponto = new javax.swing.JButton();
Bt_Igual = new javax.swing.JButton();
Bt_Soma = new javax.swing.JButton();
Bt_Raiz = new javax.swing.JButton();
Bt_00 = new javax.swing.JButton();
Bt_Potencia = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
menuBar = new javax.swing.JMenuBar();
Mn_Arquivos = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
It_Exit = 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();mainPanel.setName(“mainPanel”); // NOI18N
jScrollPane1.setName(“jScrollPane1”); // NOI18N
Total.setEditable(false);
Total.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
Total.setName(“Total”); // NOI18N
jScrollPane1.setViewportView(Total);jScrollPane2.setName(“jScrollPane2”); // NOI18N
Visor.setEditable(false);
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(calculadora.CalculadoraApp.class).getContext().getResourceMap(CalculadoraView.class);
Visor.setFont(resourceMap.getFont(“Visor.font”)); // NOI18N
Visor.setText(resourceMap.getString(“Visor.text”)); // NOI18N
Visor.setToolTipText(resourceMap.getString(“Visor.toolTipText”)); // NOI18N
Visor.setName(“Visor”); // NOI18N
Visor.setSelectedTextColor(resourceMap.getColor(“Visor.selectedTextColor”)); // NOI18N
jScrollPane2.setViewportView(Visor);Bt_Clear.setFont(resourceMap.getFont(“Bt_Clear.font”)); // NOI18N
Bt_Clear.setText(resourceMap.getString(“Bt_Clear.text”)); // NOI18N
Bt_Clear.setName(“Bt_Clear”); // NOI18N
Bt_Clear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_ClearActionPerformed(evt);
}
});Bt_Print.setFont(resourceMap.getFont(“Bt_Print.font”)); // NOI18N
Bt_Print.setText(resourceMap.getString(“Bt_Print.text”)); // NOI18N
Bt_Print.setName(“Bt_Print”); // NOI18NBt_Backspace.setFont(resourceMap.getFont(“Bt_Backspace.font”)); // NOI18N
Bt_Backspace.setText(resourceMap.getString(“Bt_Backspace.text”)); // NOI18N
Bt_Backspace.setName(“Bt_Backspace”); // NOI18N
Bt_Backspace.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_BackspaceActionPerformed(evt);
}
});Bt_7.setFont(resourceMap.getFont(“Bt_7.font”)); // NOI18N
Bt_7.setText(resourceMap.getString(“Bt_7.text”)); // NOI18N
Bt_7.setName(“Bt_7”); // NOI18N
Bt_7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_7ActionPerformed(evt);
}
});Bt_8.setFont(resourceMap.getFont(“Bt_8.font”)); // NOI18N
Bt_8.setText(resourceMap.getString(“Bt_8.text”)); // NOI18N
Bt_8.setName(“Bt_8”); // NOI18N
Bt_8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_8ActionPerformed(evt);
}
});Bt_Div.setFont(resourceMap.getFont(“Bt_Div.font”)); // NOI18N
Bt_Div.setText(resourceMap.getString(“Bt_Div.text”)); // NOI18N
Bt_Div.setName(“Bt_Div”); // NOI18N
Bt_Div.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_DivActionPerformed(evt);
}
});Bt_9.setFont(resourceMap.getFont(“Bt_9.font”)); // NOI18N
Bt_9.setText(resourceMap.getString(“Bt_9.text”)); // NOI18N
Bt_9.setName(“Bt_9”); // NOI18N
Bt_9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_9ActionPerformed(evt);
}
});Bt_4.setFont(resourceMap.getFont(“Bt_4.font”)); // NOI18N
Bt_4.setText(resourceMap.getString(“Bt_4.text”)); // NOI18N
Bt_4.setName(“Bt_4”); // NOI18N
Bt_4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_4ActionPerformed(evt);
}
});Bt_5.setFont(resourceMap.getFont(“Bt_5.font”)); // NOI18N
Bt_5.setText(resourceMap.getString(“Bt_5.text”)); // NOI18N
Bt_5.setName(“Bt_5”); // NOI18N
Bt_5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_5ActionPerformed(evt);
}
});Bt_6.setFont(resourceMap.getFont(“Bt_6.font”)); // NOI18N
Bt_6.setText(resourceMap.getString(“Bt_6.text”)); // NOI18N
Bt_6.setName(“Bt_6”); // NOI18N
Bt_6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_6ActionPerformed(evt);
}
});Bt_Mult.setFont(resourceMap.getFont(“Bt_Mult.font”)); // NOI18N
Bt_Mult.setText(resourceMap.getString(“Bt_Mult.text”)); // NOI18N
Bt_Mult.setName(“Bt_Mult”); // NOI18N
Bt_Mult.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_MultActionPerformed(evt);
}
});Bt_1.setFont(resourceMap.getFont(“Bt_1.font”)); // NOI18N
Bt_1.setText(resourceMap.getString(“Bt_1.text”)); // NOI18N
Bt_1.setName(“Bt_1”); // NOI18N
Bt_1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_1ActionPerformed(evt);
}
});Bt_3.setFont(resourceMap.getFont(“Bt_3.font”)); // NOI18N
Bt_3.setText(resourceMap.getString(“Bt_3.text”)); // NOI18N
Bt_3.setName(“Bt_3”); // NOI18N
Bt_3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_3ActionPerformed(evt);
}
});Bt_2.setFont(resourceMap.getFont(“Bt_2.font”)); // NOI18N
Bt_2.setText(resourceMap.getString(“Bt_2.text”)); // NOI18N
Bt_2.setName(“Bt_2”); // NOI18N
Bt_2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_2ActionPerformed(evt);
}
});Bt_Sub.setFont(resourceMap.getFont(“Bt_Sub.font”)); // NOI18N
Bt_Sub.setText(resourceMap.getString(“Bt_Sub.text”)); // NOI18N
Bt_Sub.setName(“Bt_Sub”); // NOI18N
Bt_Sub.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_SubActionPerformed(evt);
}
});Bt_0.setFont(resourceMap.getFont(“Bt_0.font”)); // NOI18N
Bt_0.setText(resourceMap.getString(“Bt_0.text”)); // NOI18N
Bt_0.setName(“Bt_0”); // NOI18N
Bt_0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_0ActionPerformed(evt);
}
});Bt_ponto.setFont(resourceMap.getFont(“Bt_ponto.font”)); // NOI18N
Bt_ponto.setText(resourceMap.getString(“Bt_ponto.text”)); // NOI18N
Bt_ponto.setName(“Bt_ponto”); // NOI18N
Bt_ponto.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_pontoActionPerformed(evt);
}
});Bt_Igual.setFont(resourceMap.getFont(“Bt_Igual.font”)); // NOI18N
Bt_Igual.setText(resourceMap.getString(“Bt_Igual.text”)); // NOI18N
Bt_Igual.setName(“Bt_Igual”); // NOI18N
Bt_Igual.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_IgualActionPerformed(evt);
}
});Bt_Soma.setFont(resourceMap.getFont(“Bt_Soma.font”)); // NOI18N
Bt_Soma.setText(resourceMap.getString(“Bt_Soma.text”)); // NOI18N
Bt_Soma.setName(“Bt_Soma”); // NOI18N
Bt_Soma.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_SomaActionPerformed(evt);
}
});Bt_Raiz.setFont(resourceMap.getFont(“Bt_Raiz.font”)); // NOI18N
Bt_Raiz.setText(resourceMap.getString(“Bt_Raiz.text”)); // NOI18N
Bt_Raiz.setName(“Bt_Raiz”); // NOI18N
Bt_Raiz.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_RaizActionPerformed(evt);
}
});Bt_00.setFont(resourceMap.getFont(“Bt_00.font”)); // NOI18N
Bt_00.setText(resourceMap.getString(“Bt_00.text”)); // NOI18N
Bt_00.setName(“Bt_00”); // NOI18N
Bt_00.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Bt_00ActionPerformed(evt);
}
});Bt_Potencia.setFont(resourceMap.getFont(“Bt_Potencia.font”)); // NOI18N
Bt_Potencia.setText(resourceMap.getString(“Bt_Potencia.text”)); // NOI18N
Bt_Potencia.setName(“Bt_Potencia”); // NOI18NjButton5.setFont(resourceMap.getFont(“jButton5.font”)); // NOI18N
jButton5.setText(resourceMap.getString(“jButton5.text”)); // NOI18N
jButton5.setName(“jButton5”); // NOI18Njavax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
mainPanel.setLayout(mainPanelLayout);
mainPanelLayout.setHorizontalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addComponent(Bt_Print, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_Clear, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_Backspace, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addComponent(Bt_7, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_8, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_9, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_Div, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)
.addComponent(Bt_Potencia, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addComponent(Bt_0, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_ponto, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_00, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addComponent(Bt_1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(Bt_3, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createSequentialGroup()
.addComponent(Bt_4, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_5, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_6, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(mainPanelLayout.createSequentialGroup()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Bt_Sub, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Bt_Soma, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_Igual, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(mainPanelLayout.createSequentialGroup()
.addComponent(Bt_Mult, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Bt_Raiz, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))
.addContainerGap())
);
mainPanelLayout.setVerticalGroup(
mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(Bt_Clear, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_Print, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Bt_Backspace, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(Bt_Potencia, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(Bt_7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_Div, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Bt_Raiz, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(Bt_4, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_5, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_6, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_Mult, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(mainPanelLayout.createSequentialGroup()
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(Bt_1, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_3, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_2, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addComponent(Bt_Sub, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(Bt_00, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Bt_0, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Bt_ponto, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(Bt_Soma, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(Bt_Igual, javax.swing.GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE))
.addContainerGap())
);menuBar.setName(“menuBar”); // NOI18N
Mn_Arquivos.setText(resourceMap.getString(“Mn_Arquivos.text”)); // NOI18N
Mn_Arquivos.setName(“Mn_Arquivos”); // NOI18NjMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem1.setText(resourceMap.getString(“jMenuItem1.text”)); // NOI18N
jMenuItem1.setName(“jMenuItem1”); // NOI18N
Mn_Arquivos.add(jMenuItem1);It_Exit.setText(resourceMap.getString(“It_Exit.text”)); // NOI18N
It_Exit.setName(“It_Exit”); // NOI18N
It_Exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
It_ExitActionPerformed(evt);
}
});
Mn_Arquivos.add(It_Exit);menuBar.add(Mn_Arquivos);
statusPanel.setName(“statusPanel”); // NOI18N
statusPanelSeparator.setName(“statusPanelSeparator”); // NOI18N
statusMessageLabel.setName(“statusMessageLabel”); // NOI18N
statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
statusAnimationLabel.setName(“statusAnimationLabel”); // NOI18NprogressBar.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, 410, Short.MAX_VALUE)
.addGroup(statusPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(statusMessageLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 240, 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))
);setComponent(mainPanel);
setMenuBar(menuBar);
setStatusBar(statusPanel);
}//
private void Bt_7ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)) {
Visor.setText(“7”);
}
else{
Visor.setText(Visor.getText() + “7”);
}
}private void Bt_8ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“8”);
}
else{
Visor.setText(Visor.getText() + “8”);
}
}private void Bt_9ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“9”);
}
else{
Visor.setText(Visor.getText() + “9”);
}
}private void Bt_4ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“4”);
}
else{
Visor.setText(Visor.getText() + “4”);
}
}private void Bt_5ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“5”);
}
else{
Visor.setText(Visor.getText() + “5”);
}
}private void Bt_6ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“6”);
}
else{
Visor.setText(Visor.getText() + “6”);
}
}private void Bt_1ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“1”);
}
else{
Visor.setText(Visor.getText() + “1”);
}
}private void Bt_2ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“2”);
}
else{
Visor.setText(Visor.getText() + “2”);
}
}private void Bt_3ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“3”);
}
else{
Visor.setText(Visor.getText() + “3”);
}
}private void Bt_BackspaceActionPerformed(java.awt.event.ActionEvent evt) {
String valor = Visor.getText();
if ( (!valor.equals(“0”)) && (!valor.equals("")) ){valor = valor.substring(0, valor.length()-1);
if (valor.equals("")){
Visor.setText(“0”);
}
else {
Visor.setText(valor);
}
}
}private void Bt_ClearActionPerformed(java.awt.event.ActionEvent evt) {
Visor.setText(“0”);
visor = 0;
operacao = “”;
}private void Bt_pontoActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().indexOf(",") == -1){
Visor.setText(Visor.getText() + “,”);
}
}private void Bt_SomaActionPerformed(java.awt.event.ActionEvent evt) {
if (visor==0){
visor = Double.parseDouble(Visor.getText().replace(",", “.”)); -
}
else {
visor = visor + Double.parseDouble(Visor.getText().replace(",", “.”));
}
operacao = “soma”;
Visor.setText(“0”);
}
private void Bt_SubActionPerformed(java.awt.event.ActionEvent evt) {
if (visor==0){
visor = Double.parseDouble(Visor.getText().replace(",", “.”));
}
else {
visor = visor - Double.parseDouble(Visor.getText().replace(",", “.”));
}
operacao = “subtracao”;
Visor.setText(“0”);
}
private void Bt_MultActionPerformed(java.awt.event.ActionEvent evt) {
if (visor==0){
visor = Double.parseDouble(Visor.getText().replace(",", “.”));
}
else {
visor = visor * Double.parseDouble(Visor.getText().replace(",", “.”));
}
operacao = “multiplicacao”;
Visor.setText(“0”);
}
private void Bt_DivActionPerformed(java.awt.event.ActionEvent evt) {
if (visor==0){
visor = Double.parseDouble(Visor.getText().replace(",", “.”));
}
else {
visor = visor / Double.parseDouble(Visor.getText().replace(",", “.”));
}
operacao = “divisao”;
Visor.setText(“0”);
}
private void Bt_IgualActionPerformed(java.awt.event.ActionEvent evt) {
if (!Visor.getText().equals(“0”)){
if (operacao.equals(“soma”)){
visor = visor + Double.parseDouble(Visor.getText().replace("," , “.”));
}
else if (operacao.equals(“subtracao”)){
visor = visor - Double.parseDouble(Visor.getText().replace("," , “.”));
}
else if (operacao.equals(“multiplicacao”)){
visor = visor * Double.parseDouble(Visor.getText().replace("," , “.”));
}
else if (operacao.equals("divisao")){
visor = visor / Double.parseDouble(Visor.getText().replace("," , "."));
}
}
NumberFormat nf = NumberFormat .getInstance(new Locale(“pt”, “BR”));
nf.setMinimumFractionDigits(0);
Visor.setText(nf.format(visor));
visor = 0;
operacao = “”;
}
private void Bt_0ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“0”);
}
else{
Visor.setText(Visor.getText() + “0”);
}
}
private void Bt_00ActionPerformed(java.awt.event.ActionEvent evt) {
if (Visor.getText().equals(“0”)){
Visor.setText(“00”);
}
else{
Visor.setText(Visor.getText() + “00”);
}
}
private void It_ExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
}
private void Bt_RaizActionPerformed(java.awt.event.ActionEvent evt) {
Toolkit.getDefaultToolkit().beep(); // TODO add your handling code here:
}
// Variables declaration - do not modify
private javax.swing.JButton Bt_0;
private javax.swing.JButton Bt_00;
private javax.swing.JButton Bt_1;
private javax.swing.JButton Bt_2;
private javax.swing.JButton Bt_3;
private javax.swing.JButton Bt_4;
private javax.swing.JButton Bt_5;
private javax.swing.JButton Bt_6;
private javax.swing.JButton Bt_7;
private javax.swing.JButton Bt_8;
private javax.swing.JButton Bt_9;
private javax.swing.JButton Bt_Backspace;
private javax.swing.JButton Bt_Clear;
private javax.swing.JButton Bt_Div;
private javax.swing.JButton Bt_Igual;
private javax.swing.JButton Bt_Mult;
private javax.swing.JButton Bt_Potencia;
private javax.swing.JButton Bt_Print;
private javax.swing.JButton Bt_Raiz;
private javax.swing.JButton Bt_Soma;
private javax.swing.JButton Bt_Sub;
private javax.swing.JButton Bt_ponto;
private javax.swing.JMenuItem It_Exit;
private javax.swing.JMenu Mn_Arquivos;
private javax.swing.JTextPane Total;
private javax.swing.JTextPane Visor;
private javax.swing.JButton jButton5;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
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 double visor = 0;
private String operacao = "";
private String total = "";
private JDialog aboutBox;
}
[/code]