/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author rb34
*/
//import java.awt.*;
import java.awt.Color;
import javax.swing.*;
public class ecuacion extends JFrame{
// static JFrame ventana = new JFrame("ventana");
static JButton procesar = new JButton();
static JButton borrar = new JButton();
static JLabel a = new JLabel("a");
static JLabel b = new JLabel("b");
static JLabel c = new JLabel("c");
static JLabel x = new JLabel("x");
static JLabel y = new JLabel("y");
static JTextField texta = new JTextField();
static JTextField textb = new JTextField();
static JTextField textc = new JTextField();
static JTextField textx = new JTextField();
static JTextField texty = new JTextField();
public ecuacion(){
initComponents();
}
private void initComponents(){
this.setTitle("ecuacion2");
this.setSize(500, 160);
this.setResizable(false);
this.setLayout(null);
//this.setBackground(Color.red);
procesar.setLabel("procesar");
procesar.setBounds(10, 80, 100, 30);
procesar.setBackground(Color.blue);
add(procesar);
borrar.setLabel("borrar");
borrar.setBounds(300, 80, 100, 30);
borrar.setBackground(Color.CYAN);
add(borrar);
a.setBounds(10, 10, 10, 20);
texta.setBounds(30, 10, 50, 20);
add(a);
add(texta);
b.setBounds(10, 30, 10, 20);
textb.setBounds(30, 30, 50, 20);
add(b);
add(textb);
c.setBounds(10, 50, 10, 20);
textc.setBounds(30, 50, 50, 20);
add(c);
add(textc);
x.setBounds(300, 10, 10, 20);
textx.setBounds(310, 10, 50, 20);
add(x);
add(textx);
y.setBounds(300, 30, 10, 20);
texty.setBounds(310, 30, 50, 20);
add(y);
add(texty);
this.setVisible(true);
}
public static void main(String args[]){
ecuacion demo =new ecuacion();
}
}
class evento2 implements ActionListener{
ecuacion local;
int a,b,c;
double z;
public evento2( ecuacion para){
local = para;
}
public void actionPerformed(ActionEvent evento2){
if (evento2.getSource()==local.procesar){
a = Integer.parseInt(local.texta.getText());
b = Integer.parseInt(local.textb.getText());
c = Integer.parseInt(local.textc.getText());
//z=Math.sqrt((b*b)+(-4*a*c));
local.textx.setText(" "+((-b+Math.sqrt((b*b)+(-4*a*c)))/(2*a)));
local.texty.setText(" "+((-b-Math.sqrt((b*b)+(-4*a*c)))/(2*a)));
}
if (evento2.getSource()==local.borrar){
local.texta.setText(null);
local.textb.setText(null);
local.textc.setText(null);
local.textx.setText(null);
local.texty.setText(null);
}
}
}
Mostrando entradas con la etiqueta ecuacion de segundo grado. Mostrar todas las entradas
Mostrando entradas con la etiqueta ecuacion de segundo grado. Mostrar todas las entradas
martes, 15 de marzo de 2011
Suscribirse a:
Entradas (Atom)