Calculadora em java
package pe;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class Calc1 extends JFrame implements ActionListener
{
/**
*
*/
private static final long serialVersionUID = 1L;
JButton b1;
JButton b2;
JButton b3;
JButton b4;
JButton b5;
JButton b6;
JTextField t1;
JTextField t2;
JTextField t3;
// Método Construtor da classe, reparem que ela têm o mesmo nome da classe.
public Calc1()
{
setTitle("Calculadora Simples");
setSize(350, 100);
setLocationRelativeTo(null);
setDefaultCloseOperation(3);
JLabel l1 = new JLabel("Num1.");
JLabel l2 = new JLabel("Num2.");
JLabel l3 = new JLabel("Resultado:");
this.t1 = new JTextField(5);
this.t2 = new JTextField(5);
this.t3 = new JTextField(5);
this.t3.setEditable(false);
this.b1 = new JButton("+");
this.b2 = new JButton("-");
this.b3 = new JButton("*");
this.b4 = new JButton("/");
this.b5 = new JButton("Limpar");
this.b6 = new JButton("Fechar");
this.b1.addActionListener(this);
this.b2.addActionListener(this);
this.b3.addActionListener(this);
this.b4.addActionListener(this);
this.b5.addActionListener(this);
this.b6.addActionListener(this);
getContentPane().setLayout(new GridLayout(3, 4));
getContentPane().add(l1);
getContentPane().add(this.t1);
getContentPane().add(this.b1);
getContentPane().add(this.b2);
getContentPane().add(l2);
getContentPane().add(this.t2);
getContentPane().add(this.b3);