import [Link].
*;
import [Link].*; //timestamp 15:28 brocode calculator tutorial <33
import [Link].*;
class GUI implements ActionListener{
JFrame frame;
JPanel panel;
JTextField textField; //holds numbers that is type and result
JButton []numButtons = new JButton[10];
JButton[] otherButtons = new JButton[8];
JButton delete, equals, clear, decimalpoint;
JButton add,subtract,divide,multiply;
Font calculatorFont = new Font("Ink Free", [Link], 30);
double firstNum = 0;
double secondNum = 0;
double result = 0;
GUI(){
frame = new JFrame("Calculator App ");
[Link](JFrame.EXIT_ON_CLOSE);
[Link](null);
[Link](500,500);
[Link](false);
[Link](null);
textField = new JTextField();
[Link](80, 30, 300,50);
[Link](calculatorFont);
//all calculator buttons aside from numbers
add = new JButton("+");
subtract = new JButton("-");
divide = new JButton("÷");
multiply = new JButton("x");
decimalpoint = new JButton(".");
equals = new JButton("=");
clear = new JButton("Clear");
delete = new JButton("Delete");
otherButtons[0] = add;
otherButtons[1] = subtract;
otherButtons[2] = multiply;
otherButtons[3] = divide;
otherButtons[4] = decimalpoint;
otherButtons[5] = equals;
otherButtons[6] = delete;
otherButtons[7] = clear;
for(int i =0; i<[Link]; i++){
otherButtons[i].addActionListener(this);
otherButtons[i].setFont(calculatorFont);
otherButtons[i].setFocusable(false);
}
for(int i =0; i<[Link]; i++){
numButtons[i] = new JButton([Link](i));
numButtons[i].setFont(calculatorFont);
numButtons[i].setFocusable(false);
}
panel = new JPanel();
[Link](new GridLayout(4,4,15,15)); //default calculator has 4 rows
and columns and 15 is pixels of gap
int panelX = [Link](); // Align panel with text field
int panelY = [Link]() + [Link]() + 10; // Position
below text field with 10 pixel gap
[Link](panelX, panelY, [Link](), 300);
// [Link]([Link]);
for(int i =1; i<=3; i++){
[Link](numButtons[i]);
}
[Link](add);
for(int i =4; i<=6; i++){
[Link](numButtons[i]);
}
[Link](subtract);
for(int i =7; i<=9; i++){
[Link](numButtons[i]);
}
[Link](multiply);
[Link](decimalpoint);
[Link](numButtons[0]);
[Link](equals);
[Link](divide);
[Link](80,400,140,50);
[Link](250, 400,135,50);
[Link](delete); //makes the delete button visible on the frame
[Link](clear);
[Link](panel);
[Link](textField);
[Link](true);
}
@Override
public void actionPerformed(ActionEvent e) {
for(int i =0; i<=[Link]; i++){
if([Link]()==numButtons[i]){
[Link]([Link]().concat([Link](i)));
}
}
}