Cannot Import javax.swing.JOptionPane   Please HELP!!!

import javax.swing.JOptionPane;
this line of code returns the error:
C:\Java Files\BankAccount\BankAccount_Test.java:1: Class javax.swing.JOptionPane not found in import.
import javax.swing.JOptionPane;
^
1 error
Process completed.
Please help, I don't know what the problem could be....

Swing was not part of any JDK's earlier than 1.2. Swing (or anything with a J in front of it, ie. JFrame, JOptionPane, etc...) was probably the most dramatic (if not largest) modification/addition to the Java language, that's why versions later than, and including, 1.2 are known as "Java 2".

Similar Messages

  • Import javax.swing.JOptionPane

    hello
    i just installed j2sdk1.3.1 into my redhat linux7.3, during installation, everything's fine...
    but when i start to compile a program with some import classes...i face the problem :
    cannot find type "javax/swing/JOptionPane
    this is my program :
    import javax.swing.JOptionPane;
    public class Welcome{
    public static void main(String args[])
         JOptionPane.showMessageDialog(null,"Hello");
         System.exit(0);
    can anybody help me with this problem......?...thanks

    type
    java -versionto see which version of the JVM you are running
    you could also try
    which javato see the actuall executable that you are running.

  • Cannot find class javax.swing.JOptionPane

    Hello,
    I imported the class
    import javax.swing.JOptionPane;and written as a first line of my code in the form of a .java file.
    but error occurs as : cannot find the class javax.swing.JOptionPane. What should I do.
    Thank you.

    Are you doing something likeimport javax.swing.JOptionPane;
    class Test {
        public static void main(String args[]) {
            JOptionPane.showMessageDialog(null, "Testing",
                    "Testing", JOptionPane.INFORMATION_MESSAGE);
    }Mark

  • Javax.swing.JOptionPane

    im a new programmer and i just downloaded ready to program with java and i need to import javax.swing.JOptionPane but it says it dosnt exists where can i go to get it ?
    ty for your help in advance.

    im using READY TO PROGRAM with java i unno what jdk that is sorry but umm here is the error meassage when i try to compile it.
    javax/swing/JOptionPane is either a misplaced package name or a non-existent entity. When i use this exact code at my schools computers it seems to work fine. so i unno ty for your help all

  • Importing  javax.swing.plaf.basic.BasicListUI.MouseInputHandler

    Hi!!
    I have totally no idea why I cannot import javax.swing.plaf.basic.BasicListUI.MouseInputHandler. The compiler says BasicListUI interface is expected.

    Agreed (maybe even so for 1.4.1 that I've just wiped out so I can't cehck my old rt.jar :o).
    For the moment I use my old translation of the basic.properties (and windods.properties) packed in a jar-file placed in
    jreXX/lib/ext/myLanguage.jar
    So far it works for the dialogs in my applications ...
    However, I don't find this a clean solution. I now find basic.class in rt.jar. Juged from all the other basic_xx.class files in rt.jar I guess this is where basic.properties went ... My next move will be to get hands on the source code of JAVA and check out how basic.java looks like ... perhaps this is a class filled with static fields and a simple method that sets properties in memeory or ? or ? ... In particular I need find out if some 'fields' have been added or removed compared to the old basic.properties. If so, the old translation would only be parial and my apps would be a mix of danish and english.
    I'm not really that much of a JAVA programmer and this is just to share some thoughts. Does anyone out there know a central reference on how those of us that speak minority languges easily get translations of core JAVA stuff (meaning Yes, No, Cancel and the like) take effect the easy way? Are there national boards that take care of such business?
    Maybe I haven't searched enough for information - my apologies if you found it waste of time reading this reply.
    With kind regards and thanks in advance, MJTJ

  • Swing applet- please help

    Hi,
    I am still trying to make sense of the java code...
    I thought it should be easy to create an applet, but I don't know what is wrong.
    Could anyone help me debugging it?
    Here is the code and the error msg:
    package BrImage;
    /* Example 16-3 An Image Previewer Accessory implements BrImagFile*/
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.beans.*;
    import java.io.*;
    import java.applet.Applet;
    public class BrImage extends JApplet {
    public void init() {
    getContentPane().add(new JLabel("JAppletSwing!"));
    public class BrImagFile extends javax.swing.JFrame {
    JFileChooser chooser = new JFileChooser();
    ImagePreviewer previewer = new ImagePreviewer();
    PreviewPanel previewPanel = new PreviewPanel();
    class PreviewPanel extends javax.swing.JPanel {
    public PreviewPanel() {
    JLabel label = new JLabel("Image Previewer",SwingConstants.CENTER);
    setPreferredSize(new Dimension(150,0));
    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());
    label.setBorder(BorderFactory.createEtchedBorder());
    add(label, BorderLayout.NORTH);
    add(previewer, BorderLayout.CENTER);
    public BrImagFile() {
    super("Image Previewer");
    Container contentPane = getContentPane();
    JButton button = new JButton("Select A File");
    contentPane.setLayout(new FlowLayout());
    contentPane.add(button);
    chooser.setAccessory(previewPanel);
    button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int state = chooser.showOpenDialog(null);
    File file = chooser.getSelectedFile();
    String s = "CANCELED";
    if(file != null && state == JFileChooser.APPROVE_OPTION) {
    s = "File Selected: " + file.getPath();
    /* needs to open file on the right html */
    JOptionPane.showMessageDialog(null, s);
    chooser.setFileFilter(new ImageFilter()); /*test filter */
    chooser.addPropertyChangeListener(
    new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
    if(e.getPropertyName().equals(
    JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
    File f = (File)e.getNewValue();
    String s = f.getPath(), suffix = null;
    int i = s.lastIndexOf('.');
    if(i > 0 && i < s.length() - 1)
    suffix = s.substring(i+1).toLowerCase();
    if(suffix.equals("gif") ||
    suffix.equals("jpg") ||
    suffix.equals("bmp"))
    previewer.configure(f);
    class ImagePreviewer extends javax.swing.JLabel {
    public void configure(File f) {
    Dimension size = getSize();
    Insets insets = getInsets();
    ImageIcon icon = new ImageIcon(f.getPath());
    setIcon(new ImageIcon(icon.getImage().getScaledInstance(
    size.width - insets.left - insets.right,
    size.height - insets.top - insets.bottom,
    Image.SCALE_SMOOTH)));
    class ImageFilter extends javax.swing.filechooser.FileFilter {
    public boolean accept(File f) {
    boolean accept = f.isDirectory();
    if( ! accept) {
    String suffix = getSuffix(f);
    if(suffix != null)
    accept = suffix.equals("jpg") ||
    suffix.equals("gif") ||
    suffix.equals("bmp");
    return accept;
    public String getDescription() {
    return "Image Files(*.gif *.jpg *.bmp)";
    private String getSuffix(File f) {
    String s = f.getPath(), suffix = null;
    int i = s.lastIndexOf('.');
    if(i > 0 && i < s.length() - 1)
    suffix = s.substring(i+1).toLowerCase();
    return suffix;
    public static void main(String a[]) {
    JApplet applet = new BrImage();
    JFrame f = new BrImagFile();
    f.setBounds(300, 300, 300, 75);
    applet.init();
    applet.start();
    f.setVisible(true);
    /* f.setDefaultCloseOperation(
    WindowConstants.DISPOSE_ON_CLOSE); */
    f.addWindowListener(new WindowAdapter() {
    public void windowClosed(WindowEvent e) {
    System.exit(0);
    BrImage/BrImage.java [109:1] non-static variable this cannot be referenced from a static context
    JFrame f = new BrImagFile();
    ^
    1 error
    Errors compiling BrImage.

    Hi again,
    Please help.
    JL

  • Cannot Compile....please help

    I am trying to compile the program below. I have set my class path, but this is the first time I have tried to import files. The attached program is in a folder called C:\csci3753
    My import files are in subdirectories of C:\jdk1.3.1_02
    I get the following error:
    C:\csci3753>javac -sourcepath . MultipleSelection.java
    error: cannot read: MultipleSelection.java
    1 error
    I attached the code, I think it is the way I am setting up my compile line...please help.
    // Multiple-Selection Lists
    // Copying items from one list to another.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public static void main(String[] args)
              MultipleSelection ms = new MultipleSelection();
              ms.addWindowListener(
                   new WindowAdapter() {
                        public void windowClosing(WindowEvent e)
                             System.exit(0);
    public class MultipleSelection extends JFrame
         private JList colorList, copyList;
         private JButton copy;
         private String colorName[] = {"Black", "Blue", "Cyan","Dark Gray","Gray",
         "Green","Light Gray","Magenta","Orange",
                        "Pink","Red","White","Yello","White"};
    public MultipleSelection()
              super("Multiple Selection List");
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
              colorList = new JList(colorName);
              colorList.setVisibleRowCount(5);
              colorList.setFixedCellHeight(15);
                        colorList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
              c.add(new JScrollPane(colorList));
              copy = new JButton("Copy >>>");
              copy.addActionListener(
                   new ActionListener() {
                        public void actionPerformed(ActionEvent e)
                             copyList.setListData(colorList.getSelectedValues());
              c.add(copy);
              copyList = new JList();
              copyList.setVisibleRowCount(5);
              copyList.setFixedCellWidth(100);
              copyList.setFixedCellHeight(15);
              copyList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
              c.add(new JScrollPane(copyList));
              setSize(300, 120);
              show();

    If you are compiling from the same directory as the source file, then you don't need a sourcepath. Just type:
    javac MultipleSelection.javaThe import files will be found as long as you have the C:\jdk1.3.1_02\bin directory in your command path.
    By the way, you will need to move the 'main' method into the MultipleSelection class to compile correctly.
    Hope this helps.
    Jeff Hurt

  • Can't use import javax.swing.RowFilter; in javafx

    Dear all,
    I'm a question for you.
    I developed a javafx application in which I use also swing dialog and swingx libraries.
    The question is I can't use jtable filter of java jdf 1.6
    That is when I try to add in my netbeans javafx project
    import javax.swing.RowFilter;
    it says me it's not correct library
    If I create a java swing application I can add this include.
    Why it?
    I edited netbeans conf to set javafx sdk to javafx lib I downloaded (whole sdk), not that one with netbeans, but nothing.
    It seems like I can't use this import in javafx application.
    Is it posbbile?
    Please help me

    The reason you cannot use it is because javax.swing.RowFilter was introduced in Java 1.6 . Netbeans compiles JavaFX to work with Java 1.5, which does not have the class in question.
    I have gotten around this by going to the properties->Libraries->Add JAR/Folder menu and included the jre/lib/rt.jar file from the jre directly into my project.
    Someone else posted a similar solution and more detailed explanation here: http://steveonjava.com/hacking-javafx-10-to-use-java-16-features/

  • Import javax.swing.*;

    I start my programm with:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import rechenwerk.Rechenwerk; import rechenwerk.RechenwerkFassade;
    import zahl.Zahl; import zahl.ZahlFassade;
    import oberflaeche.Oberflaeche;
    At "import javax.swing.*" i get the failure message from the compiler:
    Oktalrechner.java:8: Package javax.swing not found in import.
    import javax.swing.*;
    What is wrong? I don't know-please help me.
    I'm using JDK1.2BETA4

    Tell me when you execute java -version, what you are getting?
    Looks like you are suing old JDK.
    Download the latest public release JDK1.4 from http://java.sun.com
    /Sreenivasa Kumar Majji.
    Did somebody help you? I have a similar problem with
    javax.resource... :(
    I start my programm with:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import rechenwerk.Rechenwerk; import
    rechenwerk.RechenwerkFassade;
    import zahl.Zahl; import zahl.ZahlFassade;
    import oberflaeche.Oberflaeche;
    At "import javax.swing.*" i get the failure message
    from the compiler:
    Oktalrechner.java:8: Package javax.swing not foundin
    import.
    import javax.swing.*;
    What is wrong? I don't know-please help me.
    I'm using JDK1.2BETA4

  • Import javax.swing.* error

    Heya. I decided to learn java and i've been doing the tutorials, recently i started the swing tutorials and the learn by example page. However, whenever I try to import javax.swing.* it gives me an error. SO you know, i am using the J2SDK 1.4.2 and netbeans IDE 5.0. Here's the error text and what i type.
    import javax.swing.* ;
    the error is:
    illegal start of expression and then sometimes i get <identifier> expected.
    can anyone help me?

    To update. I figured out how to do this with a blank start file in netbeans, however it's awful to have to delete main and then make a new class file. So, is there anyway to get a blank template project or to import javax.swing.* without having to delete main and start with a blank file? SO, i guess my question has changed, but it's still about an import javax.swing.* error.
    thanks.

  • I am trying to move my itunes library from my old pc to my new imac, home sharing is on and I can see the shared library.  My problem is that when I check the shared library to import it to my imac I cannot import it.  Can anyone help me?

    I am trying to move my itunes library from my old pc to my new imac, home sharing is on and I can see the shared library.  My problem is that when I check the shared library to import it to my imac I cannot import it.  Can anyone help me?

    You need to transfer the iTunes Library from the most recent backup you made before the hard drive was replaced.
    You can't transfer the full iTunes Library from the iPad back to iTunes.
    There are third-party Windows applications that will transfer data from an iOS device, but they don't re-create the iTunes Library exactly as it was before.

  • I have my Calendar app syncing with iCloud.  Every time I open it it says, "Moving Calendars to Server Account..."  It runs and runs and does not stop.  As a result, I cannot access my calendars.  Please help.

    I have my Calendar app syncing with iCloud.  Every time I open it it says, "Moving Calendars to Server Account..."  It runs and runs and does not stop.  As a result, I cannot access my calendars.  Please help.

    I have the same problem, I tried the solution of Dr Cox but that didn't work as he said go to system preference then mail, contacts etc. but I don't have that.  Can someone help?
    Elaine

  • I have the 10.7.4 and I cannot get the Flash Player ,, please help me.

    I have the 10.7.4 and I cannot get the Flash Player ,, please help me.

    If you downloaded it, it's likely in your Downloads folder as a Disk Image .dmg. Just open it and intall Flash player and restart your browser. Everything should work.
    Clinton

  • I have an iPhone 4s. After I updated to the Operating System 7, I cannot open the WiFi. Please help.

    I have an iPhone 4s. After I updated to the Operating System 7, I cannot open the WiFi. Please help.

    Try the suggestions here to see if they resolve your problem:
    http://support.apple.com/kb/ts1559
    If these don't work you may have a hardware problem. Visit an Apple store for an evaluation or contact Apple Support.

  • I have dowloaded Photoshop + Lightroom (subscription) but no serial number have been provided for Photoshop CC so I cannot access the product. Please help

    I have dowloaded Photoshop + Lightroom (subscription) but no serial number have been provided for Photoshop CC so I cannot access the product. Please help

    Thank you Steve. Will do it straight away.
    We can can continue talking this evening, no prob.
    Rgds
    Marco
    Il giorno 16/mag/2014, alle ore 19:12, SG... <[email protected]> ha scritto:
    I have dowloaded Photoshop + Lightroom (subscription) but no serial number have been provided for Photoshop CC so I cannot access the product. Please help
    created by SG... in Photoshop General Discussion - View the full discussion
    Hi,
    When did you make the purchase? Can you try signing out of the CC desktop app, and then signing back in?
    I'll see if I can get direct support sent your way as well. How much longer are you available for this evening? We can communicate directly as well if you prefer.
    regards,
    steve
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6385161#6385161
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Photoshop General Discussion by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

Maybe you are looking for