Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By Tolls

Thread: Newbie

  1. #1
    addanny is offline Member
    Join Date
    Jul 2014
    Posts
    14
    Rep Power
    0

    Default Newbie

    Hello all. I am just starting out with Java and I am trying to understand the basics. I am trying to learn the structure from the ground up. My question is as follows. I started a new project within Netbeans. I started a package and a new class:

    package startclass;

    import javax.swing.JOptionPane;

    public class internalmsg
    {
    public static void main(String[] args)
    {
    JOptionPane.showInternalMessageDialog(frame, "information", "information", JOptionPane.Information_Message);
    }
    }

    I get an error message for the word frame in the message dialog that says: "cannot find symbol symbol: variable frame location class internalmsg". Where does it come from and how do I fix it???

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,260
    Rep Power
    6

    Default Re: Newbie

    Let me reformat a little. This will probably look wonky but I need to to illustrate

    Java Code:
    JOptionPane.showInternalMessageDialog(frame,   // <---- frame? What frame?
                                                "information", "information", JOptionPane.Information_Message);
    You do not declare a variable called 'frame' anywhere, and the compiler is telling you that.

    For the time being, you can probably make it go away by doing this:

    Java Code:
    JOptionPane.showInternalMessageDialog(null, "information", "information", JOptionPane.Information_Message);
    Until you further your studies and learn about classes, objects, variables, etc.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    addanny is offline Member
    Join Date
    Jul 2014
    Posts
    14
    Rep Power
    0

    Default Re: Newbie

    I tried the null option:

    JOptionPane.showInternalMessageDialog(null, "information", "information", JOptionPane.Information_Message);

    and that does not work. Another error message comes up and tells me that parent option is missing. This is what i didn't understand, the word frame is a variable????. Does that mean I have to declare a variable inside of the class before I use the dialog??? and what kind fo variable should it be??? (int, string .... etc)

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: Newbie

    Don't start with the basics by trying to work with a Swing GUI (or any GUI, to be honest).
    That's not the basics.

    Do some console-based apps first.
    gimbal2 likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    addanny is offline Member
    Join Date
    Jul 2014
    Posts
    14
    Rep Power
    0

    Default Re: Newbie

    That is a good idea. I did a few of those (nothing fancy as you can imagine). I have done the "Hello World" bit and a few calculate this and that and worked with classes and objects a bit ( entry level). I was just reading some forums on message boxes and I thought I would give it a try and experiment with them.The showMessageDialog one worked fine and I understand it. The internal msg one I do not understand because I don't understand what the frame component is.

  6. #6
    addanny is offline Member
    Join Date
    Jul 2014
    Posts
    14
    Rep Power
    0

    Default Re: Newbie

    Any good suggestions on some console based apps websites????

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,260
    Rep Power
    6

    Default Re: Newbie

    What Tolls said is very true. But as per the API documentation examples:

    JOptionPane (Java Platform SE 7 )

    it should have been this:

    Java Code:
    JOptionPane.showMessageDialog(null, "Hi!", "Hello", JOptionPane.INFORMATION_MESSAGE);
    So 'showMessageDialog', not 'showInternalMessageDialog'. Also INFORMATION_MESSAGE is all uppercase; Java is case sensitive.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. I am a Newbie
    By Nakul in forum Introductions
    Replies: 2
    Last Post: 06-04-2012, 11:37 AM
  2. Hi I am a Newbie
    By lijopj in forum Introductions
    Replies: 3
    Last Post: 05-06-2010, 06:37 AM
  3. Please help this newbie!
    By Scripter in forum New To Java
    Replies: 4
    Last Post: 04-05-2010, 10:21 PM
  4. :) newbie...........
    By Somitesh Chakraborty in forum Introductions
    Replies: 1
    Last Post: 08-19-2008, 10:00 AM
  5. newbie newbie newbie
    By krislogy in forum New To Java
    Replies: 9
    Last Post: 08-15-2008, 01:28 AM

Posting Permissions

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