For Programmers: Free Programming Magazines  


Home > Archive > Java Beans > September 2006 > help...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author help...
wizzywiz

2006-09-20, 3:59 am

Hi, I'm a newbie and wrote this little program and netbeans called it
Main.java.

----------------------------------------------
package letters;
import javax.swing.JOptionPane;
import java.lang.String;
public class Main {
public Main() {
}
public static void main(String[] args) {
String name = JOptionPane.showMessageDialog(null, "Hello world:
" );
}
}
---------------------------------------------

But I get this error. I imported java.lang.String so I don't understand
why it is complaining. Thanks in advance for any ideas......thanks.

---------------------------------------------
init:
deps-jar:
Compiling 1 source file to
C:\tutorial\MyJavaPrograms\Letters\Lette
rs\build\classes
C:\tutorial\MyJavaPrograms\Letters\Lette
rs\src\letters\Main.java:32:
incompatible types
found : void
required: java.lang.String
String name = JOptionPane.showMessageDialog(null, "Hello world:
" );
1 error
BUILD FAILED (total time: 0 seconds)
--------------------------------------------

IchBin

2006-09-20, 3:59 am

wizzywiz wrote:
> Hi, I'm a newbie and wrote this little program and netbeans called it
> Main.java.
>
> ----------------------------------------------
> package letters;
> import javax.swing.JOptionPane;
> import java.lang.String;
> public class Main {
> public Main() {
> }
> public static void main(String[] args) {
> String name = JOptionPane.showMessageDialog(null, "Hello world:
> " );
> }
> }
> ---------------------------------------------
>
> But I get this error. I imported java.lang.String so I don't understand
> why it is complaining. Thanks in advance for any ideas......thanks.
>
> ---------------------------------------------
> init:
> deps-jar:
> Compiling 1 source file to
> C:\tutorial\MyJavaPrograms\Letters\Lette
rs\build\classes
> C:\tutorial\MyJavaPrograms\Letters\Lette
rs\src\letters\Main.java:32:
> incompatible types
> found : void
> required: java.lang.String
> String name = JOptionPane.showMessageDialog(null, "Hello world:
> " );
> 1 error
> BUILD FAILED (total time: 0 seconds)
> --------------------------------------------
>


You just need to code JOptionPane this way. You can see in the api for
JOptionPane.

JOptionPane.showMessageDialog(null, "Hello world message","Msg Title",
JOptionPane.INFORMATION_MESSAGE);

Look at the JOptionPane API here:

http://java.sun.com/j2se/1.5.0/docs/api/

--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
________________________________________
__________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
IchBin

2006-09-20, 3:59 am

wizzywiz wrote:
> Hi, I'm a newbie and wrote this little program and netbeans called it
> Main.java.
>
> ----------------------------------------------
> package letters;
> import javax.swing.JOptionPane;
> import java.lang.String;
> public class Main {
> public Main() {
> }
> public static void main(String[] args) {
> String name = JOptionPane.showMessageDialog(null, "Hello world:
> " );
> }
> }
> ---------------------------------------------
>
> But I get this error. I imported java.lang.String so I don't understand
> why it is complaining. Thanks in advance for any ideas......thanks.
>
> ---------------------------------------------
> init:
> deps-jar:
> Compiling 1 source file to
> C:\tutorial\MyJavaPrograms\Letters\Lette
rs\build\classes
> C:\tutorial\MyJavaPrograms\Letters\Lette
rs\src\letters\Main.java:32:
> incompatible types
> found : void
> required: java.lang.String
> String name = JOptionPane.showMessageDialog(null, "Hello world:
> " );
> 1 error
> BUILD FAILED (total time: 0 seconds)
> --------------------------------------------
>


You may not want to post to this newsgroup. You really should post
questions like this to either comp.lang.java.gui or comp.lang.java.help

You just need to code JOptionPane this way. You can see in the api for
JOptionPane.

JOptionPane.showMessageDialog(null, "Hello world message","Msg Title",
JOptionPane.INFORMATION_MESSAGE);

Look at the JOptionPane API here:

http://java.sun.com/j2se/1.5.0/docs/api/


--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
________________________________________
__________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
yicong

2006-09-20, 3:59 am

is it the wrong at the first method "main()"'?
i think




"wizzywiz" <jimkk@umich.edu>
??????:1158729253.649444.114730@b28g2000cwb.googlegroups.com...
> Hi, I'm a newbie and wrote this little program and netbeans called it
> Main.java.
>
> ----------------------------------------------
> package letters;
> import javax.swing.JOptionPane;
> import java.lang.String;
> public class Main {
> public Main() {
> }
> public static void main(String[] args) {
> String name = JOptionPane.showMessageDialog(null, "Hello world:
> " );
> }
> }
> ---------------------------------------------
>
> But I get this error. I imported java.lang.String so I don't understand
> why it is complaining. Thanks in advance for any ideas......thanks.
>
> ---------------------------------------------
> init:
> deps-jar:
> Compiling 1 source file to
> C:\tutorial\MyJavaPrograms\Letters\Lette
rs\build\classes
> C:\tutorial\MyJavaPrograms\Letters\Lette
rs\src\letters\Main.java:32:
> incompatible types
> found : void
> required: java.lang.String
> String name = JOptionPane.showMessageDialog(null, "Hello world:
> " );
> 1 error
> BUILD FAILED (total time: 0 seconds)
> --------------------------------------------
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com