-
February 15th, 2011, 12:07 PM
#1
trouble with GUI
Hey guys,
this is the first GUI program I have been trying to write, I have been getting through it all so far, but once my GUI comes up I click on the button and nothing happens, any help is greatly appreciated, thanks in advance.
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;
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 answer;
double extent = 0.0;
answer = (numberField.getNumber());
extent = (numberField.getNumber());
for (int i=1; i < extent; i++) {
if(answer % 2 == 1)
{
extent=extent-1.0/(2*i-1);
answer=answer+1;
}
else
{
extent=extent+1.0/(2*i-1);
answer=answer+1;
answer = answer * 4;
}
}
numberField.setNumber(answer);
}
public static void main (String[] args){
piGUI theGUI = new piGUI();
theGUI.setSize (250, 100);
theGUI.setVisible(true);
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|