When you get compiler errors it pays to look very carfeully at the error message as it generally tells you exactly what's wrong. When the compiler says it can't find a symbol it often means either you haven't declared whatever you are referring to or you haven't spelled it correctly (the wrong case being a particularly common problem).
It's hard to tell how much experience you have based on what you said, but if you're really new to Java I'd steer clear of Swing for a while. You can do a lot and learn a lot from the command line. For instance, you might start off by just doing a simple program that uses the new Console class - which provides an easy way to get input from the command line and send output to the command line.
Swing is really intense no matter how simple your goals, and frankly it gets in the way of learning the important parts of Java.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Agree with Bert. And stop using NetBeans until you are more experienced.
Most people consider using a JOptionPane dialogue like that old-fashioned programming; if you are using Java5 or Java6 try using Scanner instead. This is your code, altered:Note: the Scanner#next method will take a single word; if you want several words use nextLine() instead. I haven't tested that code for spelling errors.
Joined: Jan 31, 2009
HI guys and thanks for the suggestions. I came across this in a workbook put out by JEDI in 2006. I am actually working through a Sun tutorial for beginners, the CDJ110 series and I am mostly using JEdit or Notepad. I confess to my frustrations at not moving faster but the slower pace is much better and things are beginning to stick. I still struggle some with the right syntax and spend a lot of time going back and looking up the right syntax. I guess that will improve.
I have NetBeans and MyEclipse on my computer but found that try to learn the language and the IDE was too troublesome and confusing for now. So, for the foreseeable future it is command line for me!
FWIW, Scanner does look simpler and more intuitive.
Joined: Jan 26, 2009
Bryant, Google Notepad++, and give it a try. It is rather nice for java. Doesn't have all the bells and whistles of an IDE, but it does highlight java reserved words, curly brackets and parenthesis, which makes life a little easier.
Joined: Oct 13, 2005
Good idea, moving slowly and avoiding IDEs at this stage.
Agree about Notepad++. A lovely application. But jEdit will do quite a lot of that too. Avoid ordinary Notepad for programming, however.
subject: Newbie is missing something... (javax.swing)