473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

reached end of file while parsing

Expand|Select|Wrap|Line Numbers
  1. import javax.swing;
  2. import java.awt.Color;
  3. import java.awt.event.ActionListener;
  4. import java.awt.event.ActionEvent;
  5.  
  6. public class TextFieldExample {
  7.  
  8.     JPanel textPanel, panelForTextFields, completionPanel;
  9.     JLabel titleLabel, usernameLabel, passwordLabel, userLabel, passLabel;
  10.     JTextField usernameField, loginField;
  11.     JButton loginButton;
  12.  
  13.     public JPanel createContentPane (){
  14.  
  15.         JPanel totalGUI = new JPanel();
  16.         totalGUI.setLayout(null);
  17.  
  18.         titleLabel = new JLabel("Login Screen");
  19.         titleLabel.setLocation(0,0);
  20.         titleLabel.setSize(290, 30);
  21.         titleLabel.setHorizontalAlignment(0);
  22.         totalGUI.add(titleLabl);
  23.  
  24.  
  25.         textPanel = new JPanel();
  26.         textPanel.setLayout(null);
  27.         textPanel.setLocation(10, 35);
  28.         textPanel.setSize(70, 80);
  29.         //totalGUI.add(textPanel);
  30.  
  31.  
  32.         usernameLabel = new JLabel("Username");
  33.         usernameLabel.setLocation(0, 0);
  34.         usernameLabel.setSize(70, 40);
  35.         usernameLabel.setHorizontalAlignment(4);
  36.         textPanel.add(usernameLabel);
  37.  
  38.  
  39.         passwordLabel = new JLabel("Password");
  40.         passwordLabel.setLocation(0, 40);
  41.         passwordLabel.setSize(70, 40);
  42.         passwordLabel.setHorizontalAlignment(4);
  43.         textPanel.add(passwordLabel);
  44.  
  45.  
  46.         panelForTextField = new JPanel();
  47.         panelForTextFields.setLayout(null);
  48.         panelForTextFields.setLocation(110, 40);
  49.         panelForTextFields.setSize(100, 70);
  50.         totalGUI.add(panelForTextFields);
  51.  
  52.  
  53.         usernameField = new JTextField(8);
  54.         usernameField.setLocation(0, 0);
  55.         usernameField.setSize(100, 30);
  56.         panelForTextFields.add(usernameField);
  57.  
  58.  
  59.         loginField = new JTextField(8);
  60.         loginField.setLocation(0, 40);
  61.         loginField.setSize(100, 30);
  62.         panelForTextFields.add(loginField);
  63.  
  64.  
  65.         completionPanel = new JPanel();
  66.         completionPanel.setLayout(null);
  67.         completionPanel.setLocation(240, 35);
  68.         completionPanel.setSize(70, 80);
  69.         totalGUI.add(completionPanel);
  70.  
  71.  
  72.         userLabel = new JLabel("Wrong");
  73.         userLabel.setForeground(Color.red);
  74.         userLabel.setLocation(0, 0);
  75.         userLabel.setSize(70, 40);
  76.         completionPanel.add(userLabel);
  77.  
  78.  
  79.         passLabel = new JLabel("Wrong");
  80.         passLabel.setForeground(Color.red);
  81.         passLabel.setLocation(0, 40);
  82.         passLabel.setSize(70, 40);
  83.         completionPanel.add(passLabel);
  84.  
  85.  
  86.         loginButton = new JButton("Login");
  87.         loginButton.setLocation(130, 120);
  88.         loginButton.setSize(80, 30);
  89.         loginButton.addActionListener();
  90.         totalGUI.add(loginButton);
  91.  
  92.         totalGUI.setOpaque(true);    
  93.         return totalGUI;
  94.     }
  95.  
  96.     // With this action performed, we simply check to see if the username and 
  97.     // password match "Bob" as the username and "Robert" as the password.
  98.     // If they do, we set the labels ajacent to them to "Correct!" and color
  99.     // them green.
  100.     // At the end, we check if both labels are green. If they are, we set the
  101.     // screen to be 'Logging In'.
  102.  
  103.     public void actionPerformed(ActionEvent e ) {
  104.  
  105.         if(e.getSource() == loginButton)
  106.         {
  107.             if(usernameField.getText().trim().compareTo("Bob") == 0)
  108.             {
  109.                 userLabel.setForeground(Color.green);
  110.                 userLabel.setText("Correct!");
  111.             }
  112.             else
  113.             {
  114.                 userLabel.setForeground(Color.red);
  115.                 userLabel.setText("Wrong!");
  116.             }
  117.  
  118.             if(loginField.getText().trim().compareTo("Robert") == 0)
  119.             {
  120.                 passLabel.setForeground(Color.green);
  121.                 passLabel.setText("Correct!");
  122.             }
  123.             else
  124.             {
  125.                 passLabel.setForeground(Color.red);
  126.                 passLabel.setText("Wrong!");
  127.             }
  128.  
  129.             if((userLabel.getForeground() == Color.green) 
  130.             && (passLabel.getForeground() == Color.green))
  131.             {
  132.                 titleLabel.setText("Logging in....");
  133.                 loginButton.setEnabled(false);
  134.             }
  135.         }
  136.     }
  137.  
  138.  
  139.     private static void createAndShowGUI() {
  140.  
  141.         JFrame.setDefaultLookAndFeelDecorated(true);
  142.         JFrame frame = new JFrame("[=] JTextField of Dreams [=]");
  143.  
  144.         TextFieldExample demo = new TextFieldExample();
  145.         frame.setContentPane(demo.createContentPane());
  146.  
  147.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  148.         frame.setSize(310, 200);
  149.         frame.setVisible(true);
  150.     }
  151.  
  152.     public static void main(String args[]) {
  153.         //Schedule a job for the event-dispatching thread:
  154.         //creating and showing this application's GUI.
  155.         SwingUtilities.invokeLater(new Runnable() {
  156.             public void run() {
  157.                 createAndShowGUI();
  158.  
  159.             }
  160.         }
  161.     }
  162. }
  163.  
heres the error:

--------------------Configuration: <Default>--------------------
C:\Users\RN3\Desktop\closet sale\TextFieldExample.java:161: ')' expected
}
^
C:\Users\RN3\Desktop\closet sale\TextFieldExample.java:163: reached end of file while parsing
}
Process completed.

any one can help guys? thanks
Sep 27 '10 #1
1 1400
Oralloy
988 Expert 512MB
James,

You're missing a closing parenthesis after the closing brace on line 160.

Cheers!
Sep 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marian Jancar | last post by:
Hi, Is there a module for parsing spec files available? Marian -- -- Best Regards,
3
by: Willem Ligtenberg | last post by:
I decided to use SAX to parse my xml file. But the parser crashes on: File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError raise exception...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
4
by: sunil | last post by:
I am creating a XML document which opens fine in IE. Implies MSXML thinks it is a well formed document. But when I try to load this document in VB.net using the following code Dim doc As New...
1
by: Christoph Bisping | last post by:
Hello! Maybe someone is able to give me a little hint on this: I've written a vb.net app which is mainly an interpreter for specialized CAD/CAM files. These files mainly contain simple movement...
11
by: .Net Sports | last post by:
In VB.net, I'm trying to do a couple of things in a couple of different blocks of code. I need to take the first 25 characters of a text file, then append at the end some ellipses and a MORE link...
1
by: Thomas Kowalski | last post by:
Hi, I have to parse a plain, ascii text file (on local HD). Since the file might be many millions lines long I want to improve the efficiency of my parsing process. The resulting data structure...
1
by: Ricardo Vazquez | last post by:
I'm writing log information into a file (via StreamWriter). When it reached a 4GB size, my MFC/C++ code copied that file to another name, truncated its length to 0 (CFile::SetLength(0)), and...
4
by: DjLethal | last post by:
Hey Guys.I am a newbie on Perl.And I have a question about file parsing by perl. I have a log file which contains reports about a communication machine.I need to take some of the reports from the...
2
by: Felipe De Bene | last post by:
I'm having problems parsing an HTML file with the following syntax : <TABLE cellspacing=0 cellpadding=0 ALIGN=CENTER BORDER=1 width='100%'> <TH BGCOLOR='#c0c0c0' Width='3%'>User ID</TH> <TH...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.