• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Newbie is missing something... (javax.swing)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone. I am quite new at this and am trying to write a little piece of code. I keep getting errors in NetBeans 6.1 and I am wondering what I am missing.

Here's the code:



The problem seems to surround JoptionPane. I am getting an error saying it cannot find the symbol.

Thanks for your help and guidance!
Bryant
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't forget Java is case sensitive. Double check your import message.
 
Bryant Evans
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! I only looked at it for a half hour trying to figure out what was wrong. I feel like I just called the Maytag repairman who discovered my washer wouldn't run because it was unplugged!




Bryant
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code is correct except that JoptionPane should be JOptionPane that's all.

Good luck!
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bryant -

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.

hth,

Bert

 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bryant Evans
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks again!

Bryant
 
Brian Pianczk
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic