/* CalculatorEngine.java
*/
import java.awt.Container;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.awt.Insets;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.BoxLayout;
import java.awt.BorderLayout;
class Calculator {
JFrame frame;
JTextField textfield;
JButton bt1, bt2, bt3;
JButton btPlus;
final static Insets insets = new Insets(0,0,0,0);
public Calculator() {
frame = new JFrame( "Calculator");
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
frame.setLayout( new GridBagLayout());
textfield = new JTextField(15);
bt1 = new JButton("1");
bt2 = new JButton("2");
bt3 = new JButton("3");
btPlus = new JButton( "+");
addComponent( frame, textfield, 0,0, 10, 1);
addComponent( frame, bt1 , 0,1, 3, 1);
addComponent( frame, bt2 , 3,1, 3, 1);
addComponent( frame, bt3 , 6,1, 3, 1);
addComponent( frame, btPlus , 9,1, 1, 1);
frame.pack();
//frame.setSize(300,300);
frame.setVisible(true);
}
public void addComponent( Container container, Component component,
int gridx, int gridy, int widthx, int widthy)
{
GridBagConstraints gbc;
gbc = new GridBagConstraints
( gridx, gridy, widthx, widthy, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
insets, 0, 0);
container.add( component, gbc);
return;
}
}
public class CalculatorEngine{
public static void main( String[] args) {
Calculator gui = new Calculator();
CalculatorEngine eng = new CalculatorEngine();
return;
}
}