CALCULATOR DESIGN IN JAVA
import java.awt.*;
class Design{
JFrame frame;
JPanel pane;
JButton btn0,btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,plus,minus,divide,multiply,equals,point;
JLabel label;
JTextField text;
public void initialize(){
frame= new JFrame("Calculator");
pane= new JPanel();
text=new JTextField();
label=new JLabel("BSCS.ICUP");
btn0= new JButton("0");
btn1= new JButton("1");
btn2= new JButton("2");btn5= new JButton("5");
btn3= new JButton("3");
btn4= new JButton("4");btn6= new JButton("6");
btn7= new JButton("7");
btn8= new JButton("8");btn9= new JButton("9");
plus= new JButton("+");
minus= new JButton("-");
divide= new JButton("/");
multiply= new JButton("*");
equals= new JButton("=");
point= new JButton(".");
pane.setLayout(new GridLayout(4,4));
pane.add(btn1);pane.add(btn2);pane.add(btn3);pane.add(plus);
pane.add(btn4);pane.add(btn5);pane.add(btn6);pane.add(minus);
pane.add(btn7);pane.add(btn8);pane.add(btn9);pane.add(divide);
pane.add(btn0);pane.add(point);pane.add(equals);pane.add(multiply);
frame.setLayout(new BorderLayout());
frame.add(text,BorderLayout.NORTH);
frame.add(pane,BorderLayout.CENTER);
frame.add(label,BorderLayout.SOUTH);
frame.setVisible(true);
frame.setSize(200,250);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public Design(){
initialize();
}
}
public class CalculatorDesigh {
public static void main(String[] args) {
new Design();
}
}
0 Comments