/*
package calculadora;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Listener extends Matematica implements ActionListener{
public void actionPerformed(ActionEvent e){
}
}
class BotonImagen extends JButton {
public BotonImagen(String imagen){
ImageIcon icono = new ImageIcon(getClass().getResource(imagen+".gif"));
Insets sinmargen = new Insets(0,0,0,0);
setIcon(icono);
setMargin(sinmargen);
setFocusable(false);
Listener listener = new Listener();
addActionListener(listener);
setActionCommand(imagen);
}
}
class Ventana extends JFrame{
Ventana(){
setLocation(300, 100);
setSize(375, 357);
setTitle("Calculadora");
setLayout(null); //Alineación de botones
setDefaultCloseOperation(Ventana.EXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
}
}
class Boton extends JButton {
public Boton(String txtBoton, int x, int y, int ancho, int alto){
Insets sinmargen = new Insets(0,0,0,0);
setBounds(x,y,ancho,alto);
setText(txtBoton);
setMargin(sinmargen);
setFont(fntBotones);
Listener listener = new Listener();
addActionListener(listener);
}
}
class Contenedor extends JPanel {
Contenedor(int x, int y, int ancho, int alto){
setBorder(BorderFactory.createEtchedBorder());
setBounds(x, y, ancho, alto);
setLayout(null);
}
}
class RadioClick extends Matematica implements ActionListener{
public void actionPerformed (ActionEvent e){
}
}
class Interfaz {
void dibujarVentana(){
System.out.println("dibujando ventana...");
Ventana ventana = new Ventana();
Font fntLabel1 = new Font("Arial Narrow",Font.ITALIC,12);
Font fntLabel2 = new Font("Arial Narrow",Font.PLAIN,25);
//-------------------------Fuentes--------------------------------
//-----------------------Contenedores-----------------------------
Container cnt = ventana.getContentPane();
Contenedor botones = new Contenedor(5,80,361,245);
cnt.add(botones);
Contenedor labels = new Contenedor(5,5,360,70);
labels.setBorder(BorderFactory.createLineBorder(Color.GRAY));
cnt.add(labels);
Contenedor tiposDatos = new Contenedor(10,10,155,40);
tiposDatos.setLayout(new GridLayout(1, 2));
botones.add(tiposDatos);
Contenedor btnMemoria = new Contenedor(170,10,181,40);
botones.add(btnMemoria);
Contenedor btnOp1 = new Contenedor(10,55,120,180);
botones.add(btnOp1);
Contenedor btnNum = new Contenedor(140,55,120,180);
botones.add(btnNum);
Contenedor btnOp2 = new Contenedor(270,55,80,180);
botones.add(btnOp2);
//-----------------------Contenedores-----------------------------
//--------------------------Labels--------------------------------
//Label lblOperacion = new Label();
lblOperacion = new Label();
lblOperacion.setText("");
lblOperacion.setBounds(1, 1, 358, 20);
lblOperacion.setBackground(Color.WHITE);
lblOperacion.setAlignment(Label.RIGHT);
lblOperacion.setFont(fntLabel1);
labels.add(lblOperacion);
//Label lblNumero = new Label();
lblNumero = new Label();
lblNumero.setText("0");
lblNumero.setBounds(1, 21, 358, 48);
lblNumero.setBackground(Color.WHITE);
lblNumero.setAlignment(Label.RIGHT);
lblNumero.setFont(fntLabel2);
labels.add(lblNumero);
//--------------------------Labels--------------------------------
//--------------------------Botones-------------------------------
//botones de memoria
cmdMC = new Boton("MC",5,5,30,30);
cmdMC.setForeground(Color.BLUE);
cmdMR = new Boton("MR",40,5,30,30);
cmdMR.setForeground(Color.BLUE);
cmdMS = new Boton("MS",75,5,30,30);
cmdMS.setForeground(Color.BLUE);
cmdMPlus = new Boton("M+",110,5,30,30);
cmdMPlus.setForeground(Color.BLUE);
cmdMLess = new Boton("M-",145,5,30,30);
cmdMLess.setForeground(Color.BLUE);
btnMemoria.add(cmdMC);
btnMemoria.add(cmdMR);
btnMemoria.add(cmdMS);
btnMemoria.add(cmdMPlus);
btnMemoria.add(cmdMLess);
//botones numericos
cmd0 = new Boton("0",5,145,70,30);
btnNum.add(cmd0);
cmd1 = new Boton("1",5,110,30,30);
btnNum.add(cmd1);
cmd2 = new Boton("2",45,110,30,30);
btnNum.add(cmd2);
cmd3 = new Boton("3",85,110,30,30);
btnNum.add(cmd3);
cmd4 = new Boton("4",5,75,30,30);
btnNum.add(cmd4);
cmd5 = new Boton("5",45,75,30,30);
btnNum.add(cmd5);
cmd6 = new Boton("6",85,75,30,30);
btnNum.add(cmd6);
cmd7 = new Boton("7",5,40,30,30);
btnNum.add(cmd7);
cmd8 = new Boton("8",45,40,30,30);
btnNum.add(cmd8);
cmd9 = new Boton("9",85,40,30,30);
btnNum.add(cmd9);
cmdPunto = new Boton(".",85,145,30,30);
btnNum.add(cmdPunto);
//botones de borrado
cmdRetro = new BotonImagen("retro");
cmdRetro.setBounds(5,5,30,30);
btnNum.add(cmdRetro);
cmdCE = new BotonImagen("CE");
cmdCE.setBounds(45,5,30,30);
btnNum.add(cmdCE);
cmdC = new BotonImagen("C");
cmdC.setBounds(85,5,30,30);
btnNum.add(cmdC);
//botones de Operacion
cmdLn = new Boton("Ln",5,5,30,30);
cmdSin = new Boton("Sin",5,40,30,30);
cmdCos = new Boton("Cos",5,75,30,30);
cmdTan = new Boton("Tan",5,110,30,30);
cmdMod = new Boton("Mod",5,145,30,30);
cmdLog = new Boton("log",45,145,30,30);
cmdFact = new Boton("n!",85,5,30,30);
cmdExponencial = new BotonImagen("exponencial");
cmdExponencial.setBounds(45,5,30,30);
cmdCuadrado = new BotonImagen("cuadrado");
cmdCuadrado.setBounds(45,40,30,30);
cmdCubo = new BotonImagen("cubo");
cmdCubo.setBounds(45,75,30,30);
cmdPotencia = new BotonImagen("potencia");
cmdPotencia.setBounds(45,110,30,30);
//botones de operacion c/imagen
cmdRaiz = new BotonImagen("raiz");
cmdRaiz.setBounds(85,40,30,30);
cmdRaizC = new BotonImagen("raizC");
cmdRaizC.setBounds(85,75,30,30);
cmdRaizN = new BotonImagen("raizN");
cmdRaizN.setBounds(85,110,30,30);
cmdBase10 = new BotonImagen("base10");
cmdBase10.setBounds(85,145,30,30);
//boton de operacion 2
cmdSigno = new Boton("±",5,5,30,30);
cmdDiv = new Boton("/",4,40,30,30);
cmdMulti = new Boton("*",5,75,30,30);
cmdResta = new Boton("-",5,110,30,30);
cmdSuma = new Boton("+",5,145,30,30);
cmdShift = new Boton("^",45,4,30,30);
cmdE = new Boton("e",45,40,30,30);
cmdPi = new Boton("Pi",45,75,30,30);
cmdIgual = new Boton("=",45,110,30,65);
//botones de tipos
grad = new JRadioButton("Grad",true);
RadioClick listener = new RadioClick();
grad.addActionListener(listener);
rad = new JRadioButton("Rad",false);
rad.addActionListener(listener);
ButtonGroup grupoOp = new ButtonGroup();
grupoOp.add(grad);
grupoOp.add(rad);
tiposDatos.add(grad);
tiposDatos.add(rad);
btnOp1.add(cmdLn);
btnOp1.add(cmdSin);
btnOp1.add(cmdCos);
btnOp1.add(cmdTan);
btnOp1.add(cmdMod);
btnOp1.add(cmdExponencial);
btnOp1.add(cmdCuadrado);
btnOp1.add(cmdCubo);
btnOp1.add(cmdPotencia);
btnOp1.add(cmdLog);
btnOp1.add(cmdFact);
btnOp1.add(cmdRaiz);
btnOp1.add(cmdRaizC);
btnOp1.add(cmdRaizN);
btnOp1.add(cmdBase10);
btnOp2.add(cmdSigno);
btnOp2.add(cmdDiv);
btnOp2.add(cmdMulti);
btnOp2.add(cmdResta);
btnOp2.add(cmdSuma);
btnOp2.add(cmdShift);
btnOp2.add(cmdE);
btnOp2.add(cmdPi);
btnOp2.add(cmdIgual);
System.out.println("fin del dibujado");
}
}