I am having trouble making the layout of a simple Calculator. What is happening is that everything appears fine except that my subtract button stays as the background and I have to guess where my other buttons are to be able to click them. When I click them I am able to see them until I unclick them. is there anyway to fix this? I'm not posting the math algorithm a it is not needed for this question.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class GUIcalc extends JFrame implements ActionListener {
private JPanel panel;
private JPanel buttonpanel;
private JPanel text;
private JLabel sumfield;
private BorderLayout layout;
private GridLayout grid;
private Container container;
private boolean toggle=true;
private float sum;
private int num1;
private int num2;
JButton one = new JButton("1");
JButton two = new JButton("2");
JButton three = new JButton("3");
JButton four = new JButton("4");
JButton five = new JButton("5");
JButton six = new JButton("6");
JButton seven = new JButton("7");
JButton eight = new JButton("8");
JButton nine = new JButton("9");
JButton zero = new JButton("0");
JButton multi = new JButton("*");
JButton divide = new JButton("/");
JButton equal = new JButton("=");
JButton add = new JButton("+");
JButton subtract = new JButton("-");
JButton deci = new JButton(".");
private final Font number= new Font("monspaced", Font.ITALIC, 20);
JFrame guiFrame;
private int counter;
/**
* @param args
*/
public GUIcalc() {
super("Calculator");
sumfield = new JLabel(""+sum);
sumfield.setLocation(0, 0);
sumfield.setSize(245, 45);
add(sumfield);
seven=new JButton("7");
seven.setLocation(0,50);
seven.setSize(50, 50);
seven.addActionListener(this);
add(seven);
eight=new JButton("8");
eight.setLocation(55,50);
eight.setSize(50, 50);
eight.addActionListener(this);
add(eight);
nine=new JButton("9");
nine.setLocation(110,50);
nine.setSize(50, 50);
nine.addActionListener(this);
add(nine);
divide=new JButton("/");
divide.setLocation(165,50);
divide.setSize(50, 50);
divide.addActionListener(this);
add(divide);
six=new JButton("6");
six.setLocation(0,105);
six.setSize(50, 50);
six.addActionListener(this);
add(six);
five=new JButton("5");
five.setLocation(55,105);
five.setSize(50, 50);
five.addActionListener(this);
add(five);
four=new JButton("4");
four.setLocation(110,105);
four.setSize(50, 50);
four.addActionListener(this);
add(four);
multi=new JButton("*");
multi.setLocation(165,105);
multi.setSize(50, 50);
multi.addActionListener(this);
add(multi);
three=new JButton("3");
three.setLocation(0,165);
three.setSize(50, 50);
three.addActionListener(this);
add(three);
two=new JButton("2");
two.setLocation(55,165);
two.setSize(50, 50);
two.addActionListener(this);
add(two);
one=new JButton("1");
one.setLocation(110,165);
one.setSize(50, 50);
one.addActionListener(this);
add(one);
add=new JButton("+");
add.setLocation(165,165);
add.setSize(50, 50);
add.addActionListener(this);
add(add);
zero=new JButton("0");
zero.setLocation(0,220);
zero.setSize(50, 50);
zero.addActionListener(this);
add(zero);
deci=new JButton(".");
deci.setLocation(55,220);
deci.setSize(50, 50);
deci.addActionListener(this);
add(deci);
equal=new JButton("=");
equal.setLocation(110,220);
equal.setSize(50, 50);
equal.addActionListener(this);
add(equal);
subtract=new JButton("-");
subtract.setLocation(165,220);
subtract.setSize(50, 50);
subtract.addActionListener(this);
add(subtract);
}