i get no GUI when i run!

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class Calculator
{
private JTextField resultTF;
private JButton calculateB, numbersB[] = new JButton[11];



public void driver()
{
//Create Window
JFrame calc = new JFrame("Calculator version 1.0");
calc.setSize(500, 500);
calc.setDefaultCloseOperation(calc.EXIT_ON_CLOSE);


//Get the content pane (object of type Container)
Container cp = calc.getContentPane();
cp.setLayout(new GridLayout(4, 3));


resultTF = new JTextField(10);


resultTF.setEditable(false);


numbersB[0] = new JButton("clear");
String num;
for(int i = 1; i<11; i++)
{
numbersB = new JButton();
numbersB.setText(Integer.toString(i-1));
}


calc.setVisible(true);


Calculator c = new Calculator();
c.driver();
}


public static void main(String[]args){
new Calculator();
}



}

Edited 3 Years Ago by Nick Evan: Fixed formatting

sorry i clicked the minus, i havent used this forum... what do you mean???

You create buttons etc but you don't add them to your JFrame.

You need to add your buttons etc to the form, otherwize they are just floating about in a vacuum. Eg

Container cp = calc.getContentPane();
...
resultTF = new JTextField(10);
[B]cp.add(resultTF);[/B]

well i did just that and Still no gui popup

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Calculator
{
	private JTextField resultTF;
	private JButton calculateB, numbersB[] = new JButton[11];


	public void driver()
	{
	//Create Window
	JFrame calc = new JFrame("Calculator version 1.0");
	calc.setSize(500, 500);
	calc.setDefaultCloseOperation(calc.EXIT_ON_CLOSE);

	//Get the content pane (object of type Container)
	Container cp = calc.getContentPane();
	cp.setLayout(new GridLayout(4, 3));

	resultTF = new JTextField(10);

	resultTF.setEditable(false);

	numbersB[0] = new JButton("clear");
	String num;
	for(int i = 1; i<11; i++)
	{
		numbersB[i] = new JButton();
		numbersB[i].setText(Integer.toString(i-1));
	}



	Calculator c = new Calculator();
	c.driver();

	cp.add(resultTF);
	for (int i=0; i<11; i++)
		{
		cp.add(numbersB[i]);
		}

	calc.setVisible(true);
	}

	public static void main(String[]args){
		new Calculator();
	}


}

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

This question has already been answered. Start a new discussion instead.