Results 1 to 2 of 2
  1. #1
    pixelctrl is offline Member
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    1
    Rep Power
    0

    Exclamation JOptionPane problems.

    Hi there,

    I've been doing a program today for my Object Orientated Programming module in college. It's been going quite well, up until now. I've got no errors, up until now. I'm getting 2 error messages where the compiler is telling me that it can't find the symbol in "JOptionPane.showMessageDialog(" with the full stop between "Pane" and "show" being the problem pointed out by the compiler.

    Here's my code:
    Java Code:
    package java_study;
    
    import java.util.Scanner;
    import javax.swing.JOptionPane;
    
    public class Java_Study {
        public static void main(String[] args) {
       
     		String providerAsString, numCallsAsString, USAAsString, AUSAsString, RUSAsString;
     		char provider;
     		int numCalls, USA, AUS, RUS;
     		final float V_RATE_USA = 0.06f, V_RATE_AUS = 0.08f, V_RATE_RUS = 0.24f,
     					E_RATE_USA = 0.19f, E_RATE_AUS = 0.85f, E_RATE_RUS = 0.92f;
    
    		Scanner input = new Scanner(System.in);
    
     		providerAsString = JOptionPane.showInputDialog("Which service did you use for the " +
     		"calls? <V - Vartec, E - Eircom>: ");
    
     		provider = providerAsString.charAt(0);
    
     		if(provider != 'V')
     		{
     			JOptionPane.showMessageDialog(null,"Which service did you use for the calls? " +
     			"<V - Vartec, E - Eircom>: " + provider + "\nSorry - incorrect choice, it must " +
     			"be <V>artec or <E>ircom...Goodbye!","Incorrect Choice",JOptionPane.ERROR_MESSAGE);
    
    			System.exit(0);
     		}
    
     		if(provider != 'E')
     		{
     			JOptionPane.showMessageDialog(null,"Which service did you use for the calls? " +
     			"<V - Vartec, E - Eircom>: " + provider + "\nSorry - incorrect choice, it must " +
     			"be <V>artec or <E>ircom...Goodbye!","Incorrect Choice",JOptionPane.ERROR_MESSAGE);
    
    			System.exit(0);
     		}
     		
     		if(provider == 'V')
     		{
     			JOptionPane.showMessageDialog(null,"You chose Vartec, is this correct?","Vartec?",
     			JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_NO_OPTION);
     		
     		}
    		
    		if (provider == 'E')
    		{
    			JOptionPane.showMessageDialog(null,"You chose Eircom, is this correct?","Eircom?",
    			JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_NO_OPTION);
    		} 		
    
    
     		numCallsAsString = JOptionPane.showInputDialog("Please enter the total number of calls made in " +
     		"the month: ");
    
    		numCalls = Integer.parseInt(numCallsAsString);
    
    		USAAsString = JOptionPane.showInputDialog("Please enter the total number of minutes spent " +
    		"calling the USA: ");
    
    		USA = Integer.parseInt(USAAsString);
    
    		AUSAsString = JOptionPane.showInputDialog("Please enter the total number of minutes spent " +
    		"calling Australia: ");
    
    		AUS = Integer.parseInt(AUSAsString);
    
    		RUSAsString = JOptionPane.showInputDialog("Please enter the total number of minutes spent " +
    		"calling Russia: ");
    
    		RUS = Integer.parseInt(RUSAsString);
    
    		JOptionPane.showMessageDialog(null,"Which service did you use for the calls? " +
    		"<V - Vartec, E - Eircom>: " + provider + "\nPlease enter the total number " +
    		"of calls made in the month: " + numCalls + "\nPlease enter the number of " +
    		"minutes spent calling the USA: " + USA + "\nPlease enter the number of " +
    		"minutes spent calling Australia: " + AUS + "\nPlease enter the number of " +
    		"minutes spent calling Russia: " + RUS + "\nThe total cost of your calls " +
    		"for the month is: EUR" + ((USA*V_RATE_USA)+(AUS*V_RATE_AUS)+(RUS*V_RATE_RUS)) + 
    		"\n\nThe average cost per call made is: EUR" + ("calculate average here")
    		,"Phone Calculations",
    		JOptionPane.INFORMATION_MESSAGE);
    
    		System.exit(0);
     	}
     }
    I know there is probably a very simple answer for this, but, I just can't seem to find it.

    Thanks in advance for any help, it's much appreciated.

    - Eoin

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: JOptionPane problems.

    Look at the line number the error code give you. Verify that your code on those lines uses an available method (see JOptionPane (Java Platform SE 6) ). You should see that for at least one of your showMessageDialog method calls you are passing incorrect number/variable types to the method (for instance, see line 42)

Similar Threads

  1. JOptionPane
    By thorobred in forum Eclipse
    Replies: 4
    Last Post: 04-19-2011, 04:15 AM
  2. InputStream/Jar Problems/File IO Problems
    By rdjava in forum Advanced Java
    Replies: 31
    Last Post: 01-17-2011, 11:12 AM
  3. Help with JOptionPane
    By sanctishit in forum New To Java
    Replies: 1
    Last Post: 03-10-2010, 10:20 AM
  4. JOptionPane
    By whosadork in forum New To Java
    Replies: 2
    Last Post: 10-23-2008, 02:17 AM
  5. problems with JOptionPane
    By oregon in forum AWT / Swing
    Replies: 2
    Last Post: 08-05-2007, 05:58 PM

Tags for this Thread

Posting Permissions

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