Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By eRaaaa

Thread: Parsing Error...

  1. #1
    Everyman's Avatar
    Everyman is offline Member
    Join Date
    Feb 2012
    Location
    Everywhere
    Posts
    26
    Rep Power
    0

    Default Parsing Error...

    Okay. So what I was supposed to be doing was "Designing and implementing a program that displays a numeric keypad that may appear on a phone. Above the keypad buttons, show a label that displays the numbers as they are picked. To the right of the keypad buttons, include another button to clear the display. Use a border layout to manage the overall presentation, and a grid layout to manage the keypad buttons. Put a border around the keypad buttons to group them visually, and a border around the display."

    This is the code:

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.BorderFactory.*;
    import javax.swing.border.Border;
    import javax.swing.border.LineBorder;
    
    public class PhoneKeys extends JFrame implements ActionListener {
    	JFrame window = new JFrame();//frame to hold the panels
    	JButton b1 = new JButton("1");
    	JButton b2 = new JButton("2");
    	JButton b3 = new JButton("3");
    	JButton b4 = new JButton("4");
    	JButton b5 = new JButton("5");
    	JButton b6 = new JButton("6");
    	JButton b7 = new JButton("7");
    	JButton b8 = new JButton("8");
    	JButton b9 = new JButton("9");
    	JButton bStar = new JButton("*");
    	JButton b0 = new JButton("0");
    	JButton bPound = new JButton("#");
    	JButton bClear = new JButton("clear");
    	JTextField tf = new JTextField(); 
    										// pressed
    	private Border lineBorder = new LineBorder(Color.BLACK, 2);
    
    	PhoneKeys() {
    		window.setSize(300,300);
    		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		window.setLayout(new BorderLayout());
    
    		// keypad panel
    		JPanel keypad = new JPanel(new GridLayout(4, 3));
    		// create buttons, with ActionListener
    		keypad.setBorder(lineBorder);
    		b1.addActionListener(this);
    		b2.addActionListener(this);
    		b3.addActionListener(this);
    		b4.addActionListener(this);
    		b5.addActionListener(this);
    		b6.addActionListener(this);
    		b7.addActionListener(this);
    		b8.addActionListener(this);
    		b9.addActionListener(this);
    		bStar.addActionListener(this);
    		bPound.addActionListener(this);
    		// add buttons to panel
    		keypad.add(b1);
    		keypad.add(b2);
    		keypad.add(b3);
    		keypad.add(b4);
    		keypad.add(b5);
    		keypad.add(b6);
    		keypad.add(b7);
    		keypad.add(b8);
    		keypad.add(b9);
    		keypad.add(bStar);
    		keypad.add(b0);
    		keypad.add(bPound);
    		
    		// create a "clear" button to clear the displayed number
    		JPanel clear = new JPanel();
    		bClear.addActionListener(this);
    		clear.add(bClear);
    		
    		// panel that displays the number of the button pressed
    		JPanel display = new JPanel();
    		JLabel lab = new JLabel();
    		lab.add(tf);
    		display.add(lab);
    		window.add(display, BorderLayout.NORTH);
    		window.add(keypad, BorderLayout.WEST);
    		window.add(clear, BorderLayout.EAST);
    		
    		
    		window.setVisible(true);
    		}
    When I try to compile with jGrasp I get this error:

    PhoneKeys.java:97: error: reached end of file while parsing
    Could anyone help me with this situation? What am i doing wrong?

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Parsing Error...

    Ouch...You have two opening brackets but only one closing brace
    and you don`t implement the ActonListener interface:
    @Override
    public void actionPerformed(ActionEvent e) {
    }
    Everyman likes this.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Parsing Error...

    Count your opening and closing braces {}

    db

    edit Stomped by eRaaaa
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Everyman's Avatar
    Everyman is offline Member
    Join Date
    Feb 2012
    Location
    Everywhere
    Posts
    26
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 09-28-2011, 09:33 AM
  2. FTP parsing remote file error
    By agangaia in forum New To Java
    Replies: 0
    Last Post: 04-18-2011, 08:45 PM
  3. Error while parsing in JNLP
    By alex1988 in forum Java Applets
    Replies: 0
    Last Post: 02-07-2011, 02:16 PM
  4. Parsing Error
    By Menre in forum Advanced Java
    Replies: 2
    Last Post: 09-01-2009, 10:16 AM
  5. Error while parsing html page in java on linux
    By rdhaware in forum Advanced Java
    Replies: 1
    Last Post: 02-20-2009, 02:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •