ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Calculadora científica Java


Enviado por   •  25 de Noviembre de 2019  •  Prácticas o problemas  •  4.408 Palabras (18 Páginas)  •  264 Visitas

Página 1 de 18

import javax.swing.*;

import javax.swing.JButton;

import java.awt.*;

import java.awt.event.*;

import java.math.MathContext;

public class calculadora extends JFrame implements ActionListener

{

public JPanel panel;

JButton b1 = new JButton();

JButton b2 = new JButton();

JButton b3 = new JButton();

JButton b4 = new JButton();

JButton b5 = new JButton();

JButton b6 = new JButton();

JButton b7 = new JButton();

JButton b8 = new JButton();

JButton b9 = new JButton();

JButton b10 = new JButton();

JButton b11 = new JButton();

JButton b12 = new JButton();

JButton b13 = new JButton();

JButton b14 = new JButton();

JButton b15 = new JButton();

JButton b16 = new JButton();

JButton b17 = new JButton();

JButton b18 = new JButton();

JButton b19 = new JButton();

JButton b20 = new JButton();

JButton b21 = new JButton();

JButton b22 = new JButton();

JButton b23 = new JButton();

JButton b24 = new JButton();

JButton b25 = new JButton();

JButton b26 = new JButton();

JButton b27 = new JButton();

JButton b28 = new JButton();

JButton b29 = new JButton();

JButton b30 = new JButton();

JButton b31 = new JButton();

JButton sqrt = new JButton();

JButton sqrt2 = new JButton();

JButton adelante = new JButton();

JButton atras = new JButton();

JTextField caja1 = new JTextField ();

double num1;

double num2;

double angulos;

double rad;

String op;

public calculadora () {

setSize(685,605); //se estabece el tamaño de la ventana

setDefaultCloseOperation(EXIT_ON_CLOSE); //close on exit

setTitle("Calculadora Científica"); //se establece el título

setLocationRelativeTo(null); //se establece la ventana en el centro

iniciarcomponentes (); //activo mis componentes

}

private void iniciarcomponentes () {

colocarpanel(); //iniciamos el panel

crearbotones(); //iniciamos los botones

colocarcajadetexto();

}

private void colocarpanel() {

panel = new JPanel (); //crear mi panel

getContentPane().add(panel); //agregar el panel

panel.setLayout(null);

}

private void crearbotones() {

b1.setText("Sin"); //establecer texto al botón

b1.setBounds(50, 140, 90, 60); //definir posición del botón

b1.addActionListener(this); //agregamos oyente de acción

// creamos botón 2

b2.setText("Cos");

b2.setBounds(150, 140, 90, 60);

b2.addActionListener(this);

//creamos botón 3

b3.setText("Tan");

b3.setBounds(250, 140, 90, 60);

b3.addActionListener(this);

//creamos botón 4

b4.setText("Sin -1");

b4.setBounds(50, 210, 90, 60);

b4.addActionListener(this);

//creamos botón 5

b5.setText("Cos -1");

b5.setBounds(150, 210, 90, 60);

b5.addActionListener(this);

//creamos botón 6

b6.setText("Tan -1");

b6.setBounds(250, 210, 90, 60);

b6.addActionListener(this);

//creamos botón 7

b7.setText("Pi");

b7.setBounds(50, 280, 90, 130);

b7.addActionListener(this);

//creamos botón 8

b8.setText("Ln");

b8.setBounds(150, 280, 90, 130);

b8.addActionListener(this);

//creamos botón 9

b9.setText("Log");

b9.setBounds(250, 280, 90, 130);

...

Descargar como (para miembros actualizados)  txt (15.2 Kb)   pdf (47.4 Kb)   docx (15.3 Kb)  
Leer 17 páginas más »
Disponible sólo en Clubensayos.com