can not find symbo error message when use JOptionPane in GUI Netbeans

Posted on 2007-09-28
Last Modified: 2013-12-14
i am new to netbeans IDE, this is the 1st time i m using Netbeans IDe 5.5,
the problem that i face is i got error message when i call JOptionPane in the actionPerformedI() handler.
below is some part od my code and error message:

given jMenuItem1 is an menu item

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                          
// TODO add your handling code here:
        javax.swing.JOptionPane.showMessageDialog(null, "File clicked");
        //JOptionPane.showMessageDialog(null, "File clicked");

the error message i got is javax => javax is not a known variable in this current context..

Question by:derredbeh
    LVL 24

    Accepted Solution

    You got to add an import at the top of your source:

    import javax.swing.JOptionPane;

    LVL 24

    Expert Comment

    I don't know NetBeans as I use ECLIPSE.
    Eclipse has a function where all missing imports are added, sorted and organised.
    I bet NetBeans has such a function.

    LVL 86

    Expert Comment

    >>javax.swing.JOptionPane.showMessageDialog(null, "File clicked");

    If that line gives you an error, you may have either a broken installation or perhaps a very early version of the JDK



    If < 1.2, you haven't got Swing

    Author Comment

    scriutiware and CEHJ, thank both of you very problem has solved...thx!!
    LVL 24

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Java 1603 Error 2 26
    Delphi Mdi application Child forms get behind control 7 67
    advance java 4 35
    parentbit challenge 3 37
    This is about my first experience with programming Arduino.
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now