| | |
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 |
addball android applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) button card class classes client code collision columns component constructor crashcourse css database designadrawingapplicationusingjavajslider draw eclipse ee error eventlistener exception expand fractal free game givemetehcodez graphics gui guidancer html ide image integration intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia jvm linux loan loop method migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle phone physics plazmic print problem program programming project radio reporting scanner server service set sharepoint smart sms smsspam software sql subclass support swing textfield threads tree trolltech unlimited utility windows






