DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Have a ")" problem I can't solve (http://www.daniweb.com/forums/thread21738.html)

buggytoast Apr 10th, 2005 11:03 pm
Have a ")" problem I can't solve
 
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 :P 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

Quote:

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

}

paradox814 Apr 11th, 2005 1:25 am
Re: Have a ")" problem I can't solve
 
 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:

 private void validateDate()
{
if ( lastTextField.getText().equals( "" ) ||
firstTextField.getText().equals( "" ) ||
addressTextField.getText().equals( "" ) ||
dateTextField.getText().equals( "" ) ||
phoneTextField.getText().equals( "" ) // end condition
)

dbs Apr 11th, 2005 1:32 am
Re: Have a ")" problem I can't solve
 
Not to up on Java but below the Private void validate date, if "("... where does this end ")"
Hope if helps

jwenting Apr 11th, 2005 3:58 am
Re: Have a ")" problem I can't solve
 
paradox nailed it


All times are GMT -4. The time now is 6:22 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC