Results 1 to 3 of 3

Thread: Gui with errors

  1. #1
    scooter24 is offline Member
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default Gui with errors

    I am trying to run the program to see if it looks right on screen and than work in the calculating part but i get the following errors:


    MortgageCalculatorGUI.java:82: ')' expected
    double rate = Double.parseDouble(rateField.getText();
    ^
    MortgageCalculatorGUI.java:84: ')' expected
    double mortgage = Double.parseDouble(mortgageField.getText();
    ^
    MortgageCalculatorGUI.java:86: ')' expected
    double term = Double.parseDouble(termField.getText();
    ^
    3 errors

    any help would be very much appreciated as this is due for submission tonight. Thanks


    Java Code:
    import java.awt.*; // import automated window tool
    import java.text.*; // import text editor
    import java.io.*;  // import input/output 
    import java.math.*; // import math calculation
    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;
    
    public class MortgageCalculatorGUI
    {
    	public static void main(String[] args)
    	{
    		JFrame frame = new MortgageCalculatorFrame();
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setVisible(true);
    	}
    
    	public class MortgageCalculatorFrame extends JFrame
    	{
    		private static final int FRAME_WIDTH = 500;
    		private static final int FRAME_HEIGHT = 500;
    	
    		private double DEFAULT_RATE = 0;
    		private double TERM = 0;
    		private double MORTGAGE_AMOUNT = 0;
    	
    		private JLabel rateLabel;
    		private JTextField rateField;
    			
    		private JLabel amountLabel;
    		private JTextField amountField;
    	
    		private JLabel termLabel;
    		private JTextField termField;
    		private JButton button;
    		private JPanel panel;
    		private JLabel resultLabel;
    	
    			public MortgageCalculatorFrame()
    			{
    				payment = new payment(PAYMENT_AMOUNT);
    	
    				resultLabel = new JLabel("Payment is: " + payment.getPayment());
    	
    				createTextField();
    				createButton();
    				createPanel();
    	
    				setSize(FRAME_WIDTH, FRAME_HEIGHT);
    			}
    			private void createTextField()
    			{
    				rateLabel = new JLabel("Interest Rate: ");
    				
    				final int FIELD_WIDTH = 10;
    				rateField = new JTextField(FIELD_WIDTH);
    				rateField.setText("" + DEFAULT_RATE);
    				
    				amountLabel = new JLabel("Mortgage Amount: ");
    				
    				mortgageField = new JTextField(FIELD_WIDTH);
    				mortgageField.setText("" + MORTGAGE_AMOUNT);
    				
    				termLabel = new JLabel("Term in years: ");
    				
    				TermField = new JTextField(FIELD_WIDTH);
    				termField.setText("" + TERM);
    			}
    			
    			private void createButton()
    			{
    				button = new JButton("Calculate Monthly Payment");
    				
    				class CalculateMonthlyPaymentListener implements ActionListener
    				{
    					public void actionPerformed(ActionEvent event)
    					{
    						double rate = Double.parseDouble(rateField.getText();
    						
    						double mortgage = Double.parseDouble(mortgageField.getText();
    						
    						double term = Double.parseDouble(termField.getText();
    						
    						resultLabel.setText("Payment: " + payment.getPayment());
    					 }
    				}
    				ActionListener listener = new CalculateMortgageListener();
    				button.addActionListener(listener);
    		} 
    		
    		private void createPanel()
    		{
    			panel = new JPanel();
    			panel.add(rateLabel);
    			panel.add(rateField);
    			panel.add(mortgageLabel);
    			panel.add(mortgageField);
    			panel.add(termLabel);
    			panel.add(termField);
    			panel.add(button);
    			panel.add(resultLabel);
    			add(panel);
    		}
    }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    The error message is very clear. It says: ')' expected
    Look at the source lines in the error message and see where there should be a )

  3. #3
    scooter24 is offline Member
    Join Date
    Jun 2011
    Posts
    4
    Rep Power
    0

    Default

    Thank you norm I just realized after reading your reply what I did not do and that was add the closing ) to each of those lines.

Similar Threads

  1. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  2. Help with three errors -.-
    By Insomniac Riot in forum New To Java
    Replies: 5
    Last Post: 03-30-2010, 06:52 PM
  3. Getting errors
    By Abbinormal in forum New To Java
    Replies: 5
    Last Post: 01-15-2010, 06:01 AM
  4. getting errors
    By ravikumar in forum Threads and Synchronization
    Replies: 3
    Last Post: 08-23-2009, 02:50 PM
  5. Replies: 3
    Last Post: 03-08-2009, 01:51 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
  •