I have to do a basic program of a calulator(text field at top for display and then all numbers) it does not have to be funtional. I know you can only have one layout manager per container...but I can't get it to work? This is what I have so far..any feedback would be great. Thanks
--------------------------------------------------------------------
// Calculator
//
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Calculator extends JFrame
{
private JButton button[];
private final String names[] =
{ "7", "8", "9", "/", "4", "5", "6", "*", "1",
"2", "3", "-", "0", ".", "=", "+"};
private JTextField field;
private GridLayout grid;
private BorderLayout boarder;
public Calculator()
{
super( "Calculator");
boarder = new BorderLayout(5,1);
Container container1 = getContentPane();
container1.setLayout( boarder );
field = new JTextField("",25);
container1.add(field, BorderLayout.NORTH);
grid = new GridLayout(4, 4, 5, 5);
Container container = getContentPane();
container.setLayout( grid );
button = new JButton[names.length];
for(int count=0; count < names.length; count++)
{
button[count] = new JButton(names[count]);
container.add(button[count]);
}
setSize(400,200);
setVisible( true );
}
public static void main( String args[] )
{
Calculator application = new Calculator();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}
----------------------------------------------------------------