I am trying to create a calculator that can perform simple arithmetic calculations but when i run the code given below only the latest button is being rendered onto the screen. If the code seems too simple that has to do with the fact that i am still very green regarding swings.
I have tried various other methods including a Jform but that ended up posing more questions than answers.
package javaapplication70;
import java.util.Scanner;
import java.awt.*;
import javax.swing.*;
public class calculatorGUI {
public static void main(String args[]){
Scanner in = new Scanner(System.in);
JFrame j = new JFrame("Calculator");
j.setSize(1000,1500);
j.setDefaultCloseOperation(3);
JTextArea jt = new JTextArea(10,40);
j.add(jt);
JButton jb15 = new JButton("C");
j.add(jb15);
JButton jb = new JButton("1");
jb.setSize(7, 7);
j.add(jb);
JButton jb1 = new JButton("2");
j.add(jb1);
JButton jb2 = new JButton("3");
j.add(jb2);
JButton jb3 = new JButton("4");
j.add(jb3);
JButton jb4 = new JButton("5");
j.add(jb4);
JButton jb5 = new JButton("6");
j.add(jb5);
JButton jb6 = new JButton("7");
j.add(jb6);
JButton jb7 = new JButton("8");
j.add(jb7);
JButton jb8 = new JButton("9");
j.add(jb8);
JButton jb9 = new JButton("0");
j.add(jb9);
JButton jb10 = new JButton("+");
j.add(jb10);
JButton jb11 = new JButton("-");
j.add(jb11);
JButton jb12 = new JButton("x");
j.add(jb12);
JButton jb13 = new JButton("/");
j.add(jb13);
JButton jb14 = new JButton("=");
j.add(jb14);
int num1=0,num2,res;
j.setVisible(true);
}
}