wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JOptionPane.showInputDialog problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JOptionPane.showInputDialog problem" Watch "JOptionPane.showInputDialog problem" New topic
Author

JOptionPane.showInputDialog problem

kunagu varun
Ranch Hand

Joined: Apr 13, 2010
Posts: 38
What i am trying to do is to get a character as an input and test whether it is vowel or not. For this purpose i want to use input box to get the input..This is the actual code i am trying to run ..


I am always getting the following error
File: G:\Java Projects\simple\JSwitch.java [line: 8]
Error: G:\Java Projects\simple\JSwitch.java:8: inconvertible types
found : java.lang.String
required: char
I have also tried with the following...


Please help me....
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
Error: G:\Java Projects\simple\JSwitch.java:8: inconvertible types
found : java.lang.String
required: char

The method returns a String NOT a char. You can't assign a String to a char.

So assign a String to a String.
kunagu varun
Ranch Hand

Joined: Apr 13, 2010
Posts: 38
ya thank you for the response..

I have also tried by initializing it as String.. If i do it so,i cannot use the variable inside switch
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2090
    
    7
Read the String API for a method that will allow you to extract a char from the String.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19538
    
  16

Make sure to check if the return value is null - if that is the case the user pressed Cancel or pressed the X. Also check if the entered string contains no characters at all.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JOptionPane.showInputDialog problem
 
Similar Threads
creating a method to get rid of a repeated code ?
More help on java modifications
Help , Help .... how to solve this problem ???
Basic Java Problem....HELP!!!!
Array without ints