Click to See Complete Forum and Search --> : matches() method is not available in Jbuilder4
sah
December 26th, 2008, 12:55 AM
i want to match a user input given in a text field with a specific pattern using matches() method in Jbuilder 4 IDE. But there is no such method available. matches() method is used as
jTextField1.getText().matches("[A-Z][a-zA-Z]*")
how can i get this method in Jbuilder4?
dlorde
December 26th, 2008, 07:25 AM
The methods available have nothing to do with the IDE you're using - they depend on the version of Java you're using. You can tell the IDE which version of Java to use, but I'd be surprised if that was the problem - the 'matches' method of String has been available since Java version 1.4 (see String.matches (http://java.sun.com/javase/6/docs/api/java/lang/String.html#matches(java.lang.String))).
If you want help with your problem, post up the relevant code (not just a single line), and the full text of any error messages you get.
It's not at all important to get it right the first time. It's vitally important to get it right the last time...
Andrew Hunt and David Thomas
sah
December 27th, 2008, 08:49 AM
when a dot is pressed in the IDE, a list of available methods is shown. But when jTextField1.getText().matches("") is written then no matches() method is shown when dot is typed after getText() method.
how can i know the version of java i use? i use jdk1.3. does it mean version 1.3? will jdk1.4 or jdk1.5 do better?
// validation module
void jButton5_actionPerformed(ActionEvent e) {
if (jTextField1.getText().matches("[A-Z][a-zA-Z]*"))
{
JOptionPane.showMessageDialog(null,"Input name is valid");
}
}
"Frame3.java": Error #: 300 : method matches(java.lang.String) not found in class java.lang.String at line 384, column 27
keang
December 27th, 2008, 09:13 AM
i use jdk1.3. does it mean version 1.3?Yes
will jdk1.4 or jdk1.5 do better?As dlorde has already stated the matches method was only added in version 1.4 so if you are using an earlier version than 1.4 (which it appears you are) then you won't have access to this method.
Java is now at version 1.6 so I would certainly advise you upgrade from 1.3.
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.