Print Friendly and PDF

Program

import javax.swing.*;
class Calculator
{
JFrame fr;
JTextField tf1;
JButton b[];
Calculator()
{
fr=new JFrame("Calculator");
fr.setLayout(null);
tf1= new JTextField();
int i;
b= new JButton[16];
for(i=0;i<9;i++)
{b[i]=new JButton("i");
}
b[10]=new JButton("+");
b[11]=new JButton("-");
b[12]=new JButton("*");
b[13]=new JButton("/");
b[14]=new JButton(".");
b[15]=new JButton("=");

//text field
tf1.setBounds(20,20,270,50);
b[0].setBounds(20,300,50,60);
b[1].setBounds(20,90,60,50);
b[2].setBounds(90,90,60,50);
b[3].setBounds(150,90,60,50);
b[4].setBounds(20,160,60,50);
b[5].setBounds(90,160,60,50);
b[6].setBounds(150,160,60,50);
b[7].setBounds(20,230,60,50);
b[8].setBounds(90,230,60,50);
b[9].setBounds(150,230,60,50);
b[10].setBounds(230,90,60,50);
b[11].setBounds(230,160,60,50);
b[13].setBounds(230,230,60,50);
b[14].setBounds(90,300,50,60);
b[15].setBounds(150,300,50,60);
b[16].setBounds(230,300,50,60);
for(i=0;i<16;i++)
{
fr.add(b[i]);
}
fr.add(tf1);
fr.setVisible(true);
fr.setSize(400,400);
}
public static void main(String []s)
{
new Calculator();
}
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: