Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: JOptionPane problem

  1. #1
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default JOptionPane problem

    oracle.com isnt being of any help to me at this point. heres my error

    client.java:18: cannot find symbol
    symbol  : variable frame
    location: class client
                    JOptionPane.showMessageDialog(frame, "testing", "testing");
                                                  ^
    1 error
    Finished!
    Press any key to continue . . .

    heres my code

    import java.lang.Object.*;
    import javax.swing.*;
     
    public class client  {
     
    public static int message = 0;
     
    public static int random(int range) {
            return (int) (Math.random() * (range + 1));
        }
     
    	public static void main(String[] args) {
    		Message();
    		JOptionPane.showMessageDialog(frame, "testing", "testing");
    	}
     
    	public static void Message() {
    		message = random(4);
    			if (message == 0) {
    				System.out.println("");
    			} else if (message == 1) {
    				System.out.println("");
    			} else if (message == 2) {
    				System.out.println("");
    			} else if (message == 3) {
    				System.out.println("");
    			} else if (message == 4) {
    				System.out.println("");
    		}
    	}
    }


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: JOptionPane problem

    The issue is very clear, Cannot find 'frame', you haven't declared anything called frame anywhere.
    If you just replace 'frame' with null, it will use a default frame for you.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,469
    My Mood
    Grumpy
    Thanks
    0
    Thanked 159 Times in 150 Posts

    Default Re: JOptionPane problem

    A classic example of copying code without understanding it.

Similar Threads

  1. Convert to JOptionPane
    By ahzim8 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2011, 08:52 AM
  2. Display in JOptionPane
    By t-rank in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 19th, 2010, 12:09 AM
  3. Change to JOptionPane
    By Liuric in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 1st, 2010, 12:07 AM
  4. JOptionPane using If and Else
    By Liuric in forum Member Introductions
    Replies: 7
    Last Post: October 1st, 2010, 12:05 AM
  5. Using Icons in JOptionPane
    By Jchang504 in forum AWT / Java Swing
    Replies: 0
    Last Post: November 28th, 2008, 07:02 PM

Tags for this Thread