0% found this document useful (0 votes)
16 views2 pages

PR 3 Only Calculator Design

The document contains a Java program that creates a simple calculator GUI using AWT. It sets up a frame with a text display and a grid of buttons for digits and operations. The layout is organized with a BorderLayout and GridLayout for the buttons.

Uploaded by

omkokate555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

PR 3 Only Calculator Design

The document contains a Java program that creates a simple calculator GUI using AWT. It sets up a frame with a text display and a grid of buttons for digits and operations. The layout is organized with a BorderLayout and GridLayout for the buttons.

Uploaded by

omkokate555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.awt.

*;

public class demo3 {


public static void main(String[] args) {
Frame frame = new Frame("Simple Calculator");

frame.setLayout(new BorderLayout());

TextField display = new TextField();


display.setEditable(false);
display.setFont(new Font("Arial", Font.BOLD, 20));
frame.add(display, BorderLayout.NORTH);

Panel buttonPanel = new Panel();


buttonPanel.setLayout(new GridLayout(4, 4, 5, 5));

Button btn7 = new Button("7");


btn7.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn7);

Button btn8 = new Button("8");


btn8.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn8);

Button btn9 = new Button("9");


btn9.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn9);

Button btnDivide = new Button("/");


btnDivide.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btnDivide);

Button btn4 = new Button("4");


btn4.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn4);

Button btn5 = new Button("5");


btn5.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn5);

Button btn6 = new Button("6");


btn6.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn6);

Button btnMultiply = new Button("*");


btnMultiply.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btnMultiply);

Button btn1 = new Button("1");


btn1.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn1);

Button btn2 = new Button("2");


btn2.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn2);

Button btn3 = new Button("3");


btn3.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn3);
Button btnSubtract = new Button("-");
btnSubtract.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btnSubtract);

Button btnClear = new Button("C");


btnClear.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btnClear);

Button btn0 = new Button("0");


btn0.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btn0);

Button btnEqual = new Button("=");


btnEqual.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btnEqual);

Button btnAdd = new Button("+");


btnAdd.setFont(new Font("Arial", Font.BOLD, 18));
buttonPanel.add(btnAdd);

frame.add(buttonPanel, BorderLayout.CENTER);

frame.setSize(300, 400);
frame.setVisible(true);

}
}

You might also like