Have a ")" problem I can't solve

Reply

Join Date: Mar 2005
Posts: 13
Reputation: buggytoast is an unknown quantity at this point 
Solved Threads: 0
buggytoast buggytoast is offline Offline
Newbie Poster

Have a ")" problem I can't solve

 
0
  #1
Apr 10th, 2005
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

// 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" );
}

}
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: Have a ")" problem I can't solve

 
0
  #2
Apr 11th, 2005
  1. private void validateDate()
  2. {
  3. if ( lastTextField.getText().equals( "" ) ||
  4. firstTextField.getText().equals( "" ) ||
  5. addressTextField.getText().equals( "" ) ||
  6. dateTextField.getText().equals( "" ) ||
  7. phoneTextField.getText().equals( "" ) || // end condition
  8. )

remove the || before the comments marks, or replace it with the following:

  1. private void validateDate()
  2. {
  3. if ( lastTextField.getText().equals( "" ) ||
  4. firstTextField.getText().equals( "" ) ||
  5. addressTextField.getText().equals( "" ) ||
  6. dateTextField.getText().equals( "" ) ||
  7. phoneTextField.getText().equals( "" ) // end condition
  8. )
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1
Reputation: dbs is an unknown quantity at this point 
Solved Threads: 0
dbs dbs is offline Offline
Newbie Poster

Re: Have a ")" problem I can't solve

 
0
  #3
Apr 11th, 2005
Not to up on Java but below the Private void validate date, if "("... where does this end ")"
Hope if helps
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Have a ")" problem I can't solve

 
0
  #4
Apr 11th, 2005
paradox nailed it
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC