import javax.swing.JPanel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.sql.*;
public class Calculator extends JFrame implements ActionListener
{
public Calculator()
{
super("Calculator");
LoadUI();
}
public void LoadUI()
{
final JFormattedTextField field = new JFormattedTextField("");
JButton add = new JButton("+");
JButton subtract = new JButton("-");
JButton divide = new JButton("/");
JButton multiply = new JButton("*");
JButton one = new JButton("1");
JButton two = new JButton("2");
JButton three = new JButton("3");
JButton four = new JButton("4");
JButton five = new JButton("5");
JButton six = new JButton("6");
JButton seven = new JButton("7");
JButton eight = new JButton("8");
JButton nine = new JButton("9");
JButton zero = new JButton("0");
JButton equals = new JButton("=");
JButton ac = new JButton("AC");
JPanel panel = new JPanel(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setBounds(0,0,400,500);
setLocationRelativeTo(null);
field.setBounds(0,0,500,50);
one.setBounds(150,120,50,50);
two.setBounds(200,120,50,50);
three.setBounds(250,120,50,50);
four.setBounds(150,170,50,50);
five.setBounds(200,170,50,50);
six.setBounds(250,170,50,50);
seven.setBounds(150,220,50,50);
eight.setBounds(200,220,50,50);
nine.setBounds(250,220,50,50);
zero.setBounds(200,270,50,50);
add.setBounds(100,120,50,50);
subtract.setBounds(100,170,50,50);
divide.setBounds(100,220,50,50);
multiply.setBounds(100,270,50,50);
equals.setBounds(250,270,50,50);
ac.setBounds(150,320,150,50);
ImageIcon imageBack = new ImageIcon("albert.JPG");
JLabel background = new JLabel(imageBack);
background.setBounds(0,0,400,500);
getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
panel.add(ac);
panel.add(equals);
panel.add(multiply);
panel.add(divide);
panel.add(subtract);
panel.add(add);
panel.add(field);
panel.add(one);
panel.add(two);
panel.add(three);
panel.add(four);
panel.add(five);
panel.add(six);
panel.add(seven);
panel.add(eight);
panel.add(nine);
panel.add(zero);
panel.add(background);
add(panel);
setVisible(true);
one.addActionListener ( new ActionListener()
{
public void actionPerformed(ActionEvent arg0)
{
field.setText("1");
}
});
}
public void actionPerformed(ActionEvent e)
{
}
}