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 2 of 2

Thread: JOPtionPane error

  1. #1
    Junior Member
    Join Date
    May 2018
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JOPtionPane error

    Hi guys im trying to make a JOption box that asks a user to input his/her name and display it back to them but keeping getting the following compile error: Cannot find symbol JOptionPane.showMessageDialog the code looks as follows, any input will be appreciated.

    import javax.swing.JOptionPane;

    public class Wack
    {
    public static void main(String args[])
    {
    String userInput = "";


    userInput = JOptionPane.showInputDialog("Please enter your name");


    userInput = "your name is " + userInput;

    JOptionPane.showMesssageDialog(null, userInput);

    }
    }

  2. #2

    Default Re: JOPtionPane error

    you can pass any JComponent as Object in the conctructor for JOptionPane,

    in your case is there null value - JOptionPane.showMessageDialog(null, "ErrorMsg", for example

    JOptionPane.showMessageDialog(myFrame,
    "ErrorMsg", "Failure", JOptionPane.ERROR_MESSAGE);

Similar Threads

  1. JOptionPane
    By Kazeth in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 29th, 2014, 11:42 PM
  2. need help in JOptionPane
    By Zuckerberg in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 28th, 2014, 06:08 AM
  3. JOptionPane error in eclipse
    By runkerr in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 26th, 2013, 05:09 PM
  4. [SOLVED] Logic error in Math.pow(a,b) using JOptionPane
    By JAKATAK in forum What's Wrong With My Code?
    Replies: 7
    Last Post: February 8th, 2013, 12:18 AM
  5. Error message when using JOptionPane
    By runkerr in forum What's Wrong With My Code?
    Replies: 7
    Last Post: February 5th, 2013, 11:17 AM