Hey, this is the first program I've tried writing using any GUI and I have gotten everything so far, except every time I click my button to try and run my program it just freezes and does not do anything.
import javax.swing.*;
import BreezySwing.*;
public class piGUI extends GBFrame{
private JLabel iterationLabel;
private JLabel numberLabel;
private DoubleField iterationField;
private DoubleField numberField;
private JButton iterationButton;
private double iteration;
private double number;
public piGUI(){
iterationLabel = addLabel ("Iterations" ,1,1,1,1);
numberLabel = addLabel ("Pi" ,1,2,1,1);
iterationField = addDoubleField (0.0 ,2,1,1,1);
numberField = addDoubleField (0.0 ,2,2,1,1);
iterationButton = addButton (">>>>>" ,3,1,1,1);}
public void buttonClicked (JButton buttonObj){
double number;
double iteration;
number = (numberField.getNumber());
iteration = (iterationField.getNumber());
for (int i=1; i < iteration; i++) {
if(number % 2 == 1)
{
number=number-1.0/(2*i-1);
i=i+1;
}
else
{
number=number+1.0/(2*i-1);
i=i+1;
number = number * 4;
}
}
numberField.setNumber(number);
}
public static void main (String[] args){
piGUI theGUI = new piGUI();
theGUI.setSize (250, 100);
theGUI.setVisible(true);
}
}