Re: Checking textfield text
the if statement never returns true even if there is no text in the field
Re: Checking textfield text
Have you placed in println statements that would test the code to make sure that your assumptions aren't incorrect?
For example:
Code:
public void actionPerformed(ActionEvent e)
{
System.out.println("1: inside of actionPerformed");
if (e.getSource() == button1) {
System.out.println("2: source == button1");
System.out.println("3: input.getText() := \"" + input.getText() + "\"");
String refined;
// I'd test it input.getText().trim().isEmpty()
if(input.getText().equals(""))//here is the problem it*** it wont work
{
System.out.println("4: input.getText() is empty");
refined = String.valueOf((int)Math.random());
System.out.println("5: refined := " + refined);
}
else
{
refined = input.getText();
}
try {
int output = (int) s1.getValue();
new Pong(output,refined);
dispose();
}catch(Exception e1) {
e.printStackTrace(); // *** don't leave this empty!!!
}
}
}
}
etc...
Re: Checking textfield text
ive checked in my pong class it wont work i even made a debugging program
Re: Checking textfield text
Quote:
Originally Posted by
jsobel
ive checked in my pong class it wont work i even made a debugging program
Well that's where doing debugging tricks will help -- they will help tell why things aren't happening. If you're still stuck, you'd best show us your debugging attempt and then tell us about the output from your debug statements.