| | |
Have a ")" problem I can't solve
![]() |
•
•
Join Date: Mar 2005
Posts: 13
Reputation:
Solved Threads: 0
WEll I'm kinda new to Java programming...but we got a major project coming up and I got stuck on one of the examples. This is for a validation code, to validate correct inputs....the errors are highlighted in red...Thanks to anyone that bothered to help
I'm sure the answer is really basic but i tried flipping stuff around and it doesn't work :evil: supposedly i'm missing an ")" but no friggin idea where. -__-ll
I'm sure the answer is really basic but i tried flipping stuff around and it doesn't work :evil: supposedly i'm missing an ")" but no friggin idea where. -__-ll•
•
•
•
// Airlines Reservation program
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Airlines extends JFrame {
private JTextField phoneTextField, firstTextField, lastTextField, dateTextField, addressTextField;
/** Creates a new instance of Airlines */
public Airlines() {
super ( "Airlines");
JLabel phoneLabel = new JLabel( "Phone" );
JLabel firstLabel = new JLabel( "First Name" );
JLabel lastLabel = new JLabel( "Last Name" );
JLabel dateLabel = new JLabel( "Date" );
JLabel addressLabel = new JLabel( "Address" );
JButton okButton = new JButton( "OK" );
okButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event ){
validateDate();
}
}
);
phoneTextField = new JTextField( 15 );
firstTextField = new JTextField( 5 );
lastTextField = new JTextField( 2 );
addressTextField = new JTextField( 12 );
dateTextField = new JTextField( 20 );
JPanel firstName = new JPanel();
firstName.add( firstLabel );
firstName.add( firstTextField );
JPanel lastName = new JPanel();
lastName.add( lastLabel );
lastName.add( lastTextField );
JPanel address = new JPanel();
address.add( addressLabel );
address.add( addressTextField );
JPanel date = new JPanel();
date.add( dateLabel );
date.add( dateTextField );
JPanel phone = new JPanel();
phone.add( phoneLabel );
phone.add( phoneTextField );
JPanel ok = new JPanel();
ok.add( okButton );
Container container = getContentPane();
container.setLayout( new GridLayout( 6, 1 ) );
container.add( firstName );
container.add( lastName );
container.add( address );
container.add( date );
container.add( phone );
container.add( ok );
setSize( 400, 400 );
setVisible( true );
}
public static void main( String args[]){
Airlines application = new Airlines();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
private void validateDate()
{
if ( lastTextField.getText().equals( "" ) ||
firstTextField.getText().equals( "" ) ||
addressTextField.getText().equals( "" ) ||
dateTextField.getText().equals( "" ) ||
phoneTextField.getText().equals( "" ) || // end condition
)
JOptionPane.showMessageDialog(this, "Fill in all fields please");
else if(!lastTextField.getText().matches( "[A-Z][a-zA-Z]*"))
JOptionPane.showMessageDialog( this, "Invalid last name" );
else if(!firstTextField.getText().matches( "[A-Z][a-zA-Z]*"))
JOptionPane.showMessageDialog( this, "Invalid first name" );
else JOptionPane.showMessageDialog( this, "Thanks Bub" );
}
}
Java Syntax (Toggle Plain Text)
private void validateDate() { if ( lastTextField.getText().equals( "" ) || firstTextField.getText().equals( "" ) || addressTextField.getText().equals( "" ) || dateTextField.getText().equals( "" ) || phoneTextField.getText().equals( "" ) || // end condition )
remove the || before the comments marks, or replace it with the following:
Java Syntax (Toggle Plain Text)
private void validateDate() { if ( lastTextField.getText().equals( "" ) || firstTextField.getText().equals( "" ) || addressTextField.getText().equals( "" ) || dateTextField.getText().equals( "" ) || phoneTextField.getText().equals( "" ) // end condition )
![]() |
Similar Threads
- tell me how to solve "counting Problem" in a BTree ? (C++)
- Local Area Connection shows "Limited or no connectivity" (Windows NT / 2000 / XP)
- Runtime Error "7" Out Of Memory (Windows NT / 2000 / XP)
- Problem with "\n" (C++)
- System 32 at startup and "dwn"/"down" pop up at startup (Viruses, Spyware and other Nasties)
- "Page cannot be displayed" -must keep refreshing (Web Browsers)
- URL's (Links) in MSN.com "Hotmail" do not work. (Web Browsers)
Other Threads in the Java Forum
- Previous Thread: Need Help with controling the speed of animation
- Next Thread: Is ArrayList Better than Vector
| Thread Tools | Search this Thread |
911 actionlistener addball addressbook android api append applet application array arrays automation binary bluetooth button character chat class client code component consumer css csv database desktop eclipse ee error fractal ftp game givemetehcodez graphics gui html ide image integer j2me japplet java javaarraylist javac javaee javaprojects jni jpanel julia jvm linked linux list loan mac map method methods mobile netbeans newbie objects online oriented output panel phone printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server service set sms software sort sql string swing test threads time transfer tree ubuntu update windows working






