The Artima Developer Community
Sponsored Link

Java Answers Forum
GUI problem

1 reply on 1 page. Most recent reply: Apr 4, 2005 1:38 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Terry

Posts: 1
Nickname: thefarside
Registered: Apr, 2005

GUI problem Posted: Apr 1, 2005 6:59 AM
Reply to this message Reply
Advertisement
Could anybody help me, the below program will not run correctly. The program will compile without errors but when run no messageBoxes appear.

Thanks for any help.


import javax.swing.*;
import BreezySwing.*;

public class FactorGUI extends GBFrame{



JLabel NumberLabel = addLabel
("Number" ,1,1,1,1);
//JLabel trialfactorLabel = addLabel
//("Trialfactor" ,1,2,1,1);
IntegerField numberField = addIntegerField
(0,2,1,1,1);
//IntegerField trialfactorField = addIntegerField
//(0.0,2,2,1,1);
JButton NumberButton = addButton
(">>>>>>" ,3,1,1,1);


int sum;
int trialfactor;
int number;

public void buttonClicked (JButton buttonObj){


if(trialfactor <= (number/2)){
if(number % trialfactor == 0){
sum = (trialfactor + sum);
}else{
}
trialfactor = (trialfactor + 1);
}

if (trialfactor > (number/2)){
if (sum < number){
messageBox("Deficient");
}else if (sum == number){
messageBox("Perfect");
}else if (sum > number){
messageBox("Abundant");
}


}
}

public static void main (String[] args) {
FactorGUI tpo = new FactorGUI();
tpo.setSize(320, 200);
tpo.setVisible(true);
}
}


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: GUI problem Posted: Apr 4, 2005 1:38 AM
Reply to this message Reply
My first guess is that ButtonClicked never get's called.

I dont't know BreezySwing and can't say if it assigns a actionlistener for the button.

Try printing out some text at the ctritical locations.

Btw: It is more stylish to use a constructor instead of creating all the variables outside any method.

Flat View: This topic has 1 reply on 1 page
Topic: Convert String (IP & Port) into InetAddress Previous Topic   Next Topic Topic: Changing classpath during runtime

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use