Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
cp.setLayout(null);
st = (String)chLevel.getSelectedItem();
Object obj = new String("Object");
String str = null;
if (obj instanceof String)
str = (String)obj;
[code]
You could also just catch the exception and handle it that way. I personally do not like that for it make the code harder to read, and just is not as clean.
Anyways I hope this helps you... have fun...
Rodney
[URL unfurl="true"]http://www.javathis.com[/URL]
btnRegister.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// Add validation code here...
// If everything is good then
// preform your registration code...
// If something is invalid you may
// you may want to prompt a option
// informing the user of ALL the errors
// then when the user OK's this
// message then take them to the field
// of the first error, and select all
// the text for them.
}
});
public class MyApplet extends JApplet
{
actionPreformed()
{
boolean isValid = true;
ArrayList invalidFields = new ArrayList();
if (fieldOne is not valid)
{
isValid = false;
invalidFields.add(fieldOne.getName());
}
if (fieldTwo is not valid)
{
isValid = false;
invalidFields.add(fieldTwo .getName());
}
..etc..
if (!isValid)
{
Iterator iter = invalidFields.iterator();
String[] message = new String[invalidFields.size() + 1];
message[0] = "The following components have failed validation:";
for (int i = 1; i < message.length; i++
message[i] = (String)iter.next();
JOptionPane.showMessageDialog(MyApplet.this, message, "
Validation Failed", JOptionPane.ERROR_MESSAGE)
}
else
{
...Everything is okay, so complete registration...
}
}
}