Como crear una calculadora en java

Cerrado
jaul1977 - 11 oct 2009 a las 04:21
KARLA-BOTAS Mensajes enviados 2 Fecha de inscripción viernes, 20 de mayo de 2016 Estatus Miembro Última intervención viernes, 20 de mayo de 2016 - 20 may 2016 a las 08:34
Hola,
Consulta también:

1 respuesta

package programacion2.ventana;

import javax.swing.*;

public class ejemploventana1 extends javax.swing.JFrame {

double valor1 = 0;
double valor2 = 0;
double valor3 = 0;
String funcion = "";
private Object math;

public ejemploventana1() {
initComponents();
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

buttonGroup1 = new javax.swing.ButtonGroup();
jLabel8 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
jLabel22 = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("XD");
setBackground(new java.awt.Color(0, 204, 102));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setFocusTraversalPolicyProvider(true);
setLocationByPlatform(true);

jTextField1.setEditable(false);
jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

jLabel1.setBackground(new java.awt.Color(51, 153, 255));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel1.setText(" 1");
jLabel1.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel1.setOpaque(true);
jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel1MouseClicked(evt);
}
});

jLabel2.setBackground(new java.awt.Color(51, 153, 255));
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel2.setText(" 2");
jLabel2.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel2.setOpaque(true);
jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel2MouseClicked(evt);
}
});

jLabel3.setBackground(new java.awt.Color(51, 153, 255));
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel3.setText(" 4");
jLabel3.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel3.setOpaque(true);
jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel3MouseClicked(evt);
}
});

jLabel4.setBackground(new java.awt.Color(51, 153, 255));
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel4.setText(" 3");
jLabel4.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel4.setOpaque(true);
jLabel4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel4MouseClicked(evt);
}
});

jLabel5.setBackground(new java.awt.Color(51, 153, 255));
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel5.setText(" 5");
jLabel5.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel5.setOpaque(true);
jLabel5.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel5MouseClicked(evt);
}
});

jLabel6.setBackground(new java.awt.Color(51, 153, 255));
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel6.setText(" 6");
jLabel6.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel6.setOpaque(true);
jLabel6.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel6MouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
jLabel6MouseEntered(evt);
}
});

jLabel7.setBackground(new java.awt.Color(51, 153, 255));
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel7.setText(" 7");
jLabel7.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel7.setOpaque(true);
jLabel7.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel7MouseClicked(evt);
}
});

jLabel9.setBackground(new java.awt.Color(51, 153, 255));
jLabel9.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel9.setText(" 8");
jLabel9.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel9.setOpaque(true);
jLabel9.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel9MouseClicked(evt);
}
});

jLabel10.setBackground(new java.awt.Color(51, 153, 255));
jLabel10.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel10.setText(" 9");
jLabel10.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel10.setOpaque(true);
jLabel10.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel10MouseClicked(evt);
}
});

jLabel11.setBackground(new java.awt.Color(51, 153, 255));
jLabel11.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel11.setText(" +");
jLabel11.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel11.setOpaque(true);
jLabel11.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel11MouseClicked(evt);
}
});

jLabel12.setBackground(new java.awt.Color(51, 153, 255));
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel12.setText(" -");
jLabel12.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel12.setOpaque(true);
jLabel12.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel12MouseClicked(evt);
}
});

jLabel13.setBackground(new java.awt.Color(51, 153, 255));
jLabel13.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel13.setText(" /");
jLabel13.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel13.setOpaque(true);
jLabel13.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel13MouseClicked(evt);
}
});

jLabel15.setBackground(new java.awt.Color(51, 153, 255));
jLabel15.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel15.setText(" 0");
jLabel15.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel15.setOpaque(true);
jLabel15.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel15MouseClicked(evt);
}
});

jLabel17.setBackground(new java.awt.Color(51, 153, 255));
jLabel17.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel17.setText(" .");
jLabel17.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel17.setOpaque(true);
jLabel17.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel17MouseClicked(evt);
}
});

jLabel18.setBackground(new java.awt.Color(51, 153, 255));
jLabel18.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel18.setText(" =");
jLabel18.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel18.setOpaque(true);
jLabel18.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel18MouseClicked(evt);
}
});

jLabel19.setBackground(new java.awt.Color(51, 153, 255));
jLabel19.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel19.setText(" *");
jLabel19.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel19.setOpaque(true);
jLabel19.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel19MouseClicked(evt);
}
});

jLabel20.setBackground(new java.awt.Color(51, 153, 255));
jLabel20.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel20.setText("BORRAR");
jLabel20.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel20.setOpaque(true);
jLabel20.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel20MouseClicked(evt);
}
});

jLabel14.setBackground(new java.awt.Color(51, 153, 255));
jLabel14.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel14.setText(" %");
jLabel14.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel14.setOpaque(true);
jLabel14.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel14MouseClicked(evt);
}
});

jLabel21.setBackground(new java.awt.Color(51, 153, 255));
jLabel21.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel21.setText(" sqrt");
jLabel21.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel21.setOpaque(true);
jLabel21.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel21MouseClicked(evt);
}
});

jLabel22.setBackground(new java.awt.Color(51, 153, 255));
jLabel22.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel22.setText(" ?");
jLabel22.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel22.setOpaque(true);
jLabel22.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel22MouseClicked(evt);
}
});

jLabel23.setBackground(new java.awt.Color(51, 153, 255));
jLabel23.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel23.setText(" 1/x");
jLabel23.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel23.setOpaque(true);
jLabel23.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel23MouseClicked(evt);
}
});

jLabel24.setBackground(new java.awt.Color(51, 153, 255));
jLabel24.setFont(new java.awt.Font("Tahoma", 1, 18));
jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jLabel24.setText(" ^");
jLabel24.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 51)));
jLabel24.setOpaque(true);
jLabel24.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jLabel24MouseClicked(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()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(98, 98, 98)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel16)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(82, 82, 82)
.addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 35, /*
* Botones.java
*
* Created on 1 de noviembre de 2006, 20:53
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

/**
*
* @author prueba
*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.math.*;

public class Botones extends java.applet.Applet {
char signo, sgnmenos='-';
String numero="";
int num7=7, num8=8, num9=9, num6=6, num5=5, num4=4, num3=3, num2=2, num1=1, num0=0,cont=0;
double x,y,numpi=Math.PI, nume=Math.E;
String var7,var8,var9,var6,var5,var4,var3,var2,var1,var0,varpunto;
Label etiq1, etiq2;
Button boton1, boton2, boton3, boton4, boton5, boton6, boton7, boton8, boton9, boton0;
Button decimal, igual, suma, resta, mult, div;
Button loga, raiz, seno, coseno, tangente, pi, potencia,potencia2,potencia3,factorial,ln,ex,e;
Button senh, cosh, tanh, botonC,btnsigno;
Button porciento;
TextField cuadro, color1, color2, color3;
double resp,rad;
Image img;

Button amarillo, azul, rojo, verde, gris, naranja, blanco, personalizado, aplicar, cerrar;
Label fondo;
int r,g,b;
String red,green,blue;

Label colorR, colorG, colorB;

public void init() {
initcomponents();
}

void initcomponents() {
colorR=new Label("Rojo");
colorR.setBackground(Color.BLACK);
colorR.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
colorR.setForeground(Color.red);
colorR.setAlignment(1);
colorR.setVisible(false);
setLayout(null);
add(colorR);
colorR.setBounds(5,350,60,25);

colorG=new Label("Verde");
colorG.setBackground(Color.BLACK);
colorG.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
colorG.setForeground(Color.green);
colorG.setAlignment(1);
colorG.setVisible(false);
setLayout(null);
add(colorG);
colorG.setBounds(80,350,60,25);

colorB=new Label("Azul");
colorB.setBackground(Color.BLACK);
colorB.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
colorB.setForeground(Color.blue);
colorB.setAlignment(1);
colorB.setVisible(false);
setLayout(null);
add(colorB);
colorB.setBounds(155,350,60,25);

etiq2=new Label("Colores Calculadora");
etiq2.setBackground(Color.BLACK);
etiq2.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
etiq2.setForeground(Color.green);
setLayout(null);
add(etiq2);
etiq2.setBounds(5,5,150,30);

amarillo=new Button("Amarillo");
amarillo.setBackground(Color.yellow);
amarillo.setForeground(Color.black);
amarillo.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
setLayout(null);
add(amarillo);
amarillo.setBounds(5,40,100,30);

amarillo.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
amarilloMouseClicked(evt);
}
});

azul=new Button("Azul");
azul.setBackground(Color.blue);
azul.setForeground(Color.black);
azul.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
setLayout(null);
add(azul);
azul.setBounds(5,75,100,30);

azul.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
azulMouseClicked(evt);
}
});


rojo=new Button("Rojo");
rojo.setBackground(Color.red);
rojo.setForeground(Color.black);
rojo.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
setLayout(null);
add(rojo);
rojo.setBounds(5,110,100,30);

rojo.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
rojoMouseClicked(evt);
}
});

gris=new Button("Gris");
gris.setBackground(Color.gray);
gris.setForeground(Color.black);
gris.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
setLayout(null);
add(gris);
gris.setBounds(5,145,100,30);

gris.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
grisMouseClicked(evt);
}
});

verde=new Button("Verde");
verde.setBackground(Color.green);
verde.setForeground(Color.black);
verde.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
setLayout(null);
add(verde);
verde.setBounds(5,180,100,30);

verde.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
verdeMouseClicked(evt);
}
});


naranja=new Button("Naranja");
naranja.setBackground(Color.orange);
naranja.setForeground(Color.black);
naranja.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
setLayout(null);
add(naranja);
naranja.setBounds(5,215,100,30);

naranja.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
naranjaMouseClicked(evt);
}
});

blanco=new Button("Blanco");
blanco.setBackground(Color.white);
blanco.setForeground(Color.black);
blanco.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
setLayout(null);
add(blanco);
blanco.setBounds(5,250,100,30);

blanco.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
blancoMouseClicked(evt);
}
});

personalizado=new Button("Personalizado");
personalizado.setBackground(new Color(125,154,168));
personalizado.setForeground(Color.black);
personalizado.setFont(new Font("Comic Sans MS", Font.BOLD, 12));
setLayout(null);
add(personalizado);
personalizado.setBounds(5,285,100,30);

personalizado.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
personalizadoMouseClicked(evt);
}
});

aplicar=new Button("Aplicar");
aplicar.setBackground(new Color(200,240,185));
aplicar.setForeground(Color.black);
aplicar.setFont(new Font("Comic Sans MS", Font.BOLD, 12));
aplicar.setVisible(false);
setLayout(null);
add(aplicar);
aplicar.setBounds(60,390,100,30);

aplicar.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
aplicarMouseClicked(evt);
}
});

cerrar=new Button("Cerrar");
cerrar.setBackground(new Color(55,88,200));
cerrar.setForeground(Color.black);
cerrar.setFont(new Font("Comic Sans MS", Font.BOLD, 12));
cerrar.setVisible(false);
setLayout(null);
add(cerrar);
cerrar.setBounds(60,430,100,30);

cerrar.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
cerrarMouseClicked(evt);
}
});

color1 = new TextField();
color1.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
color1.setForeground(Color.black);
color1.setBackground(Color.white);
color1.setVisible(false);
setLayout(null);
add(color1);
color1.setBounds(5,320,60,25);

color2 = new TextField();
color2.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
color2.setForeground(Color.black);
color2.setBackground(Color.white);
color2.setVisible(false);
setLayout(null);
add(color2);
color2.setBounds(80,320,60,25);

color3 = new TextField();
color3.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
color3.setForeground(Color.black);
color3.setBackground(Color.white);
color3.setVisible(false);
setLayout(null);
add(color3);
color3.setBounds(155,320,60,25);


//aparece el 7 al presionar el boton
boton7= new Button();
boton7.setBackground(Color.black);
boton7.setForeground(Color.green);
boton7.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton7.setLabel("7");
setLayout(null);
add(boton7);
boton7.setBounds(400,100,30,30);

//Escuchador boton 7

boton7.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
boton7MouseClicked(evt);
}
});

//aparece el 8 al presionar el boton

boton8= new Button();
boton8.setBackground(Color.black);
boton8.setForeground(Color.green);
boton8.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton8.setLabel("8");
setLayout(null);
add(boton8);
boton8.setBounds(440,100,30,30);

//Escuchador boton 7

boton8.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
//aqui tarea
boton8MouseClicked(evt);
}
});


//aparece el 9 al presionar el boton
boton9= new Button();
boton9.setBackground(Color.black);
boton9.setForeground(Color.green);
boton9.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton9.setLabel("9");
setLayout(null);
add(boton9);
boton9.setBounds(480,100,30,30);

boton9.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
boton9MouseClicked(evt);
}
});



boton6= new Button();
boton6.setBackground(Color.black);
boton6.setForeground(Color.green);
boton6.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton6.setLabel("6");
setLayout(null);
add(boton6);
boton6.setBounds(480,140,30,30);

boton6.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
boton6MouseClicked(evt);
}
});


boton5= new Button();
boton5.setBackground(Color.black);
boton5.setForeground(Color.green);
boton5.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton5.setLabel("5");
setLayout(null);
add(boton5);
boton5.setBounds(440,140,30,30);

boton5.addMouseListener(new MouseAdapter(){
public void mouseClicked (MouseEvent evt) {
boton5MouseClicked(evt);
}
});


boton4= new Button();
boton4.setBackground(Color.black);
boton4.setForeground(Color.green);
boton4.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton4.setLabel("4");
setLayout(null);
add(boton4);
boton4.setBounds(400,140,30,30);

boton4.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
boton4MouseClicked(evt);
}
});


boton3= new Button();
boton3.setBackground(Color.black);
boton3.setForeground(Color.green);
boton3.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton3.setLabel("3");
setLayout(null);
add(boton3);
boton3.setBounds(480,180,30,30);

boton3.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
boton3MouseClicked(evt);
}
});


boton2= new Button();
boton2.setBackground(Color.black);
boton2.setForeground(Color.green);
boton2.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton2.setLabel("2");
setLayout(null);
add(boton2);
boton2.setBounds(440,180,30,30);

boton2.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
boton2MouseClicked(evt);
}
});


boton1= new Button();
boton1.setBackground(Color.black);
boton1.setForeground(Color.green);
boton1.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton1.setLabel("1");
setLayout(null);
add(boton1);
boton1.setBounds(400,180,30,30);

boton1.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
boton1MouseClicked(evt);
}
});

boton0= new Button();
boton0.setBackground(Color.black);
boton0.setForeground(Color.green);
boton0.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
boton0.setLabel("0");
setLayout(null);
add(boton0);
boton0.setBounds(400,220,30,30);

boton0.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
boton0MouseClicked(evt);
}
});



botonC= new Button();
botonC.setBackground(Color.black);
botonC.setForeground(Color.green);
botonC.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
botonC.setLabel("C");
setLayout(null);
add(botonC);
botonC.setBounds(180,180,30,70);

botonC.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
botonCMouseClicked(evt);
}
});

btnsigno= new Button();
btnsigno.setBackground(Color.black);
btnsigno.setForeground(Color.green);
btnsigno.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
btnsigno.setLabel("+/-");
setLayout(null);
add(btnsigno);
btnsigno.setBounds(180,140,30,30);

btnsigno.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
btnsignoMouseClicked(evt);
}
});

porciento= new Button();
porciento.setBackground(Color.black);
porciento.setForeground(Color.green);
porciento.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
porciento.setLabel("%");
setLayout(null);
add(porciento);
porciento.setBounds(180,100,30,30);

porciento.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
porcientoMouseClicked(evt);
}
});


decimal= new Button();
decimal.setBackground(Color.red);
decimal.setForeground(Color.white);
decimal.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
decimal.setLabel(".");
setLayout(null);
add(decimal);
decimal.setBounds(440,220,30,30);

decimal.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
decimalMouseClicked(evt);
}
});

igual= new Button();
igual.setBackground(Color.red);
igual.setForeground(Color.white);
igual.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
igual.setLabel("=");
setLayout(null);
add(igual);
igual.setBounds(480,220,30,30);

igual.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
igualMouseClicked(evt);
}
});

suma= new Button();
suma.setBackground(Color.red);
suma.setForeground(Color.white);
suma.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
suma.setLabel("+");
setLayout(null);
add(suma);
suma.setBounds(520,100,30,30);

suma.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
sumaMouseClicked(evt);
}
});


resta= new Button();
resta.setBackground(Color.red);
resta.setForeground(Color.white);
resta.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
resta.setLabel("-");
setLayout(null);
add(resta);
resta.setBounds(520,140,30,30);

resta.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
restaMouseClicked(evt);
}
});


mult= new Button();
mult.setBackground(Color.red);
mult.setForeground(Color.white);
mult.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
mult.setLabel("*");
setLayout(null);
add(mult);
mult.setBounds(520,180,30,30);

mult.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
multMouseClicked(evt);
}
});


div= new Button();
div.setBackground(Color.red);
div.setForeground(Color.white);
div.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
div.setLabel("/");
setLayout(null);
add(div);
div.setBounds(520,220,30,30);

div.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
divMouseClicked(evt);
}
});

seno= new Button();
seno.setForeground(Color.RED);
seno.setFont(new Font("Verdana",Font.BOLD,12));
seno.setLabel("sen");
setLayout(null);
add(seno);
seno.setBounds(340,100,30,30);

seno.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
senoMouseClicked(evt);
}
});

loga= new Button();
loga.setLabel("log");
loga.setForeground(new Color(10,180,100));
loga.setFont(new Font("Comic Sans MS", Font.BOLD,12));
setLayout(null);
add(loga);
loga.setBounds(220,180,30,30);

loga.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
logaMouseClicked(evt);
}
});


raiz= new Button();
raiz.setLabel("sqrt");
raiz.setFont(new Font("Arial",Font.BOLD,12));
setLayout(null);
add(raiz);
raiz.setBounds(220,140,30,30);


raiz.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
raizMouseClicked(evt);
}
});


coseno= new Button();
coseno.setForeground(Color.RED);
coseno.setFont(new Font("Verdana",Font.BOLD,12));
coseno.setLabel("cos");
setLayout(null);
add(coseno);
coseno.setBounds(340,140,30,30);

coseno.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
cosenoMouseClicked(evt);
}
});

tangente= new Button();
tangente.setForeground(Color.RED);
tangente.setFont(new Font("Verdana",Font.BOLD,12));
tangente.setLabel("tan");
setLayout(null);
add(tangente);
tangente.setBounds(340,180,30,30);

tangente.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
tangenteMouseClicked(evt);
}
});

pi= new Button();
pi.setLabel("pi");
pi.setForeground(new Color(11,15,166));
pi.setFont(new Font("Arial",Font.BOLD,12));
setLayout(null);
add(pi);
pi.setBounds(340,220,30,30);

pi.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
piMouseClicked(evt);
}
});

potencia= new Button();
potencia.setLabel("x^y");
potencia.setForeground(new Color(190,18,10));
potencia.setFont(new Font("Arial",Font.BOLD,12));
setLayout(null);
add(potencia);
potencia.setBounds(260,180,30,30);

potencia.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
potenciaMouseClicked(evt);
}
});

potencia2= new Button();
potencia2.setForeground(new Color(190,18,10));
potencia2.setFont(new Font("Arial",Font.BOLD,12));
potencia2.setLabel("x^2");
setLayout(null);
add(potencia2);
potencia2.setBounds(260,100,30,30);

potencia2.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
potencia2MouseClicked(evt);
}
});

potencia3= new Button();
potencia3.setLabel("x^3");
potencia3.setForeground(new Color(190,18,10));
potencia3.setFont(new Font("Arial",Font.BOLD,12));
setLayout(null);
add(potencia3);
potencia3.setBounds(260,140,30,30);

potencia3.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
potencia3MouseClicked(evt);
}
});

factorial= new Button();
factorial.setLabel("n!");
factorial.setFont(new Font("Arial",Font.BOLD,12));
setLayout(null);
add(factorial);
factorial.setBounds(220,100,30,30);

factorial.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
factorialMouseClicked(evt);
}
});


ln= new Button();
ln.setLabel("ln");
ln.setForeground(new Color(10,180,100));
ln.setFont(new Font("Comic Sans MS", Font.BOLD,12));
setLayout(null);
add(ln);
ln.setBounds(220,220,30,30);

ln.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
lnMouseClicked(evt);
}
});

ex= new Button();
ex.setLabel("e^x");
ex.setForeground(new Color(190,18,10));
ex.setFont(new Font("Arial",Font.BOLD,12));
setLayout(null);
add(ex);
ex.setBounds(260,220,30,30);

ex.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
exMouseClicked(evt);
}
});

e= new Button();
e.setLabel("e");
e.setForeground(new Color(11,15,166));
e.setFont(new Font("Arial",Font.BOLD,12));
setLayout(null);
add(e);
e.setBounds(300,220,30,30);

e.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
eMouseClicked(evt);
}
});

senh= new Button();
senh.setLabel("senh");
senh.setForeground(new Color(10,100,190));
senh.setFont(new Font("Comic Sans MS", Font.BOLD,12));
setLayout(null);
add(senh);
senh.setBounds(300,100,30,30);

senh.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
senhMouseClicked(evt);
}
});

cosh= new Button();
cosh.setLabel("cosh");
cosh.setForeground(new Color(10,100,190));
cosh.setFont(new Font("Comic Sans MS", Font.BOLD,12));
setLayout(null);
add(cosh);
cosh.setBounds(300,140,30,30);

cosh.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
coshMouseClicked(evt);
}
});

tanh= new Button();
tanh.setLabel("tanh");
tanh.setForeground(new Color(10,100,190));
tanh.setFont(new Font("Comic Sans MS", Font.BOLD,12));
setLayout(null);
add(tanh);
tanh.setBounds(300,180,30,30);

tanh.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent evt){
tanhMouseClicked(evt);
}
});

cuadro = new TextField();
cuadro.setEditable(false);
cuadro.setFont(new Font("Comic Sans MS", Font.BOLD, 14));
cuadro.setForeground(Color.BLUE);
setLayout(null);
add(cuadro);
cuadro.setBounds(220,60,332,22);


//Fondo
fondo=new Label();
fondo.setBackground(Color.gray);
setLayout(null);
add(fondo);
fondo.setBounds(170,40,400,225);
}

public void boton7MouseClicked(MouseEvent evt){
cuadro.setText(num7+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void boton8MouseClicked(MouseEvent evt){
cuadro.setText(num8+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}


public void boton9MouseClicked(MouseEvent evt){
cuadro.setText(num9+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void boton4MouseClicked(MouseEvent evt){
cuadro.setText(num4+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void boton5MouseClicked(MouseEvent evt){
cuadro.setText(num5+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void boton6MouseClicked(MouseEvent evt){
cuadro.setText(num6+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void boton1MouseClicked(MouseEvent evt){
cuadro.setText(num1+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void boton2MouseClicked(MouseEvent evt){
cuadro.setText(num2+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void boton3MouseClicked(MouseEvent evt){
cuadro.setText(num3+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void boton0MouseClicked(MouseEvent evt){
cuadro.setText(num0+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void piMouseClicked(MouseEvent evt) {
cuadro.setText(numpi+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void decimalMouseClicked(MouseEvent evt){
cont =evt.getClickCount();
if(cont < 2){
cuadro.setText(".");
numero+=cuadro.getText();
cuadro.setText(numero);
}
}

public void potenciaMouseClicked(MouseEvent evt){
x=Double.parseDouble(cuadro.getText());
signo='p';
numero="";
}

public void sumaMouseClicked(MouseEvent evt){
x=Double.parseDouble(cuadro.getText());
signo='+';
numero="";
}

public void restaMouseClicked(MouseEvent evt){
x=Double.parseDouble(cuadro.getText());
signo='-';
numero="";
}

public void multMouseClicked(MouseEvent evt){
x=Double.parseDouble(cuadro.getText());
signo='*';
numero="";
}

public void divMouseClicked(MouseEvent evt){
x=Double.parseDouble(cuadro.getText());
signo='/';
numero="";
}

public void senoMouseClicked(MouseEvent evt){
x=Double.parseDouble(cuadro.getText());
rad = Math.toRadians(x);
resp=Math.sin(rad);
cuadro.setText(resp+"");
}

public void logaMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
resp=Math.log10(x);
cuadro.setText(resp+"");
}

public void raizMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
if (x<0) {
cuadro.setText("Error: raíz cuadrada de número negativo");
}
else {
resp=Math.sqrt(x);
cuadro.setText(resp+"");
}
}

public void cosenoMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
rad = Math.toRadians(x);
resp=Math.cos(rad);
cuadro.setText(resp+"");
}

public void tangenteMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
if (x%90==0) {
cuadro.setText("Error: Tangente de "+x);
x=0;
resp=0;
}
else {
rad = Math.toRadians(x);
resp=Math.tan(rad);
cuadro.setText(resp+"");
}
}

public void potencia2MouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
resp=Math.pow(x,2);
cuadro.setText(resp+"");
numero="";
}

public void potencia3MouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
resp=Math.pow(x,3);
cuadro.setText(resp+"");
numero="";
}

public void factorialMouseClicked(MouseEvent evt) {
double cont1=1,r=1;
x=Double.parseDouble(cuadro.getText());
do {
r*=cont1;
cont1++;
}
while(cont1<=x);
cuadro.setText(r+"");
}

public void lnMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
if (x>0) {
resp=Math.log(x);
cuadro.setText(resp+"");
}
else {
cuadro.setText("Error: logaritmo natural de un número negativo");
cuadro.setFont(new Font("Comic Sans MS", Font.BOLD, 12));
cuadro.setForeground(Color.BLUE);
}

}

public void exMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
resp=Math.pow(Math.E,x);
cuadro.setText(resp+"");
}

public void eMouseClicked(MouseEvent evt) {
cuadro.setText(nume+"");
numero+=cuadro.getText();
cuadro.setText(numero);
}

public void senhMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
resp=Math.sinh(x);
cuadro.setText(resp+"");
}

public void coshMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
resp=Math.cosh(x);
cuadro.setText(resp+"");
}

public void tanhMouseClicked(MouseEvent evt) {
x=Double.parseDouble(cuadro.getText());
resp=Math.tanh(x);
cuadro.setText(resp+"");
}

public void botonCMouseClicked(MouseEvent evt) {
numero="";
x=0.0;
resp=0.0;
y=0;
cuadro.setText("0");
}

public void btnsignoMouseClicked(MouseEvent evt) {
//double b;
cuadro.setText(sgnmenos+"");
numero+=cuadro.getText();
cuadro.setText(numero);
//int cont=0;
//cont=cont+evt.getClickCount();
cuadro.setText("-"+" ");
x=Double.parseDouble(cuadro.getText()) * (-1);
}

public void porcientoMouseClicked(MouseEvent evt){
x=Double.parseDouble(cuadro.getText());
signo='%';
numero="";
}

public void igualMouseClicked(MouseEvent evt){
y=Double.parseDouble(cuadro.getText());
numero="";
if(signo=='+')
{
resp=x+y;
cuadro.setText(resp+"");
}

if(signo=='-')
{
resp=x-y;
cuadro.setText(resp+"");
}
if(signo=='*')
{
resp=x*y;
cuadro.setText(resp+"");
}
if(signo=='/')
{
if(y!=0) {
resp=x/y;
cuadro.setText(resp+"");
}
else
cuadro.setText("Error: division por cero");
}

if(signo=='p')
{
resp=Math.pow(x,y);
cuadro.setText(resp+"");
15
esa porkeria no sirve has algo bien ps capullo
0
ptm para k cuelgas esta wada no hace nada tiene mas errores como el k lo hizo
0
Le falta la clase principal main ...
0
tu madre
0
KARLA-BOTAS Mensajes enviados 2 Fecha de inscripción viernes, 20 de mayo de 2016 Estatus Miembro Última intervención viernes, 20 de mayo de 2016
20 may 2016 a las 08:34
Hola!! espero y te sirva
Hace días me di a la tarea de investigar como se realiza una calculadora muy básica en Netbean te dejo el link de mi vídeo ojala sea de tu ayuda.



https://www.youtube.com/watch?v=7R35G0hHfF0

suerte, Saludos
0