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

Thread: what is the

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    27
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default what is the

    well i have a swing component that supposed to write strings on a jtextarea
    but i have a problem with tread that updates that string everything compiles but when used
    some Exception is thrown ....




    what dose it mean what is the problem?????



    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: PFrame$Ru
    nClass
            at PFrame.songGeter(PFrame.java:92)
            at ActListener.actionPerformed(ActListener.java:28)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
    95)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
    )
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6038)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
            at java.awt.Component.processEvent(Component.java:5803)
            at java.awt.Container.processEvent(Container.java:2058)
            at java.awt.Component.dispatchEventImpl(Component.java:4410)
            at java.awt.Container.dispatchEventImpl(Container.java:2116)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322
    )
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
     
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
            at java.awt.Container.dispatchEventImpl(Container.java:2102)
            at java.awt.Window.dispatchEventImpl(Window.java:2429)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
    ad.java:273)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
    java:183)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:173)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
     
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
     
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)



    here is my code


           public void songGeter(File inputFile)
                { 
     
                  myDirectory = inputFile;
     
                  FileGeter dir1 = new FileGeter();
     
                  dir1.fileGet(myDirectory);
     
                  Thread myThread = new Thread(new RunClass(dir1));
     
                  myThread.start();
     
                }
     
     
     
    public class RunClass implements Runnable
    {
     
    FileGeter dir1;
     
     
     public RunClass(FileGeter dir)
    { 
     this.dir1 =dir;
    }
     
    public void run() {
     
                     Id3Tag tag1;
                     Collections.sort(dir1.bFiles, new Mp3Comparator()); // in the comparator the files that are sent to id3tag well show as is there's no tag because of the sorting -don't mind
     
                     if (!dir1.bFiles.isEmpty() ){  // if open
                            for (int h = 0 ; h < dir1.bFiles.size(); h++)
                             {
                              tag1 = new Id3Tag(dir1.bFiles.get(h)); 
     
                              setTextBox(tag1.getArtist());
     
                             }
                                                                                               }  //if close
                          else 
                          {
                           //System.out.println("no files "+myDirectory.exists());
                          }
                      }
     
     
     
     
          public  void setTextBox(final String str)
          {
           SwingUtilities.invokeLater(new Runnable() {
                            public void run() 
                                        {
                                          textBox.append(str +'\n');
                                        }
     
                    });          
     
          }
     
     
     
    }

    thanks

  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: what is the

    I think its telling you that it cant find the class RunClass

    Where is the method songGeter defined?

    // Json

  3. The Following User Says Thank You to Json For This Useful Post:

    mdstrauss (October 11th, 2009)

  4. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    27
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Re: what is the

    in my main frame (EDT) that has a listener (separate class) that uses the songGeter...
    the program compiles but when run it is wired sometimes it works some times it shows what i posted
    i maybe i need to stop the thread or something ???
    Last edited by mdstrauss; October 11th, 2009 at 04:27 PM.

  5. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: what is the

    Could I see the code of PFrame.java please?

    // Json

  6. The Following User Says Thank You to Json For This Useful Post:

    mdstrauss (October 11th, 2009)

  7. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    27
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Re: what is the

    ok here it is i changed a couple things and it worked a couple times
    do you think i should stop the thread (try finely block) or put an executor instead????
    ok here is the full code thanks allot i really appreciate your help.....






    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
     
     
     
    public class PFrame extends JFrame
    {
       File myDirectory;
       JPanel pane1 = new JPanel();
       JPanel pane2 = new JPanel();
       JPanel pane3 = new JPanel();
     
       JButton browse;
       JButton artist;
       JButton name;
       JTextArea textBox;
       JScrollPane scroll;
       JLabel numLabel;
       int count=0;
     
     
       public PFrame()
       { 
         super("mikey's program");
         setSize(350, 400);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
         browse = new JButton("browse"); 
         browse.setActionCommand("browse button");
         ActListener demo = new ActListener();
         browse.addActionListener(demo);
         textBox = new JTextArea();
         textBox.setEditable(false);
         scroll = new JScrollPane(textBox);
         numLabel = new JLabel("number of songs:" +count);
         artist = new JButton("artist");
         name = new JButton("name");
     
         BoxLayout box = new BoxLayout(pane1, BoxLayout.Y_AXIS);
         pane1.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
         pane1.setLayout(box); 
         pane1.add(browse);
         pane1.add(Box.createRigidArea(new Dimension(0, 10)));
         pane1.add(scroll);
         pane1.add(numLabel);
     
         pane2.setLayout(new FlowLayout(FlowLayout.LEFT));
         pane2.add(artist);
         pane2.add(name);
     
         pane3.setLayout(new BoxLayout(pane3, BoxLayout.X_AXIS));
         pane3.add(pane1);
         pane3.add(pane2);
     
       add(pane3);
     
       //try{
       //    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
       //    SwingUtilities.updateComponentTreeUI(this);
       //   } catch (Exception e){
       //     e.getMessage();
       //                }
     
     
     
     
       demo.getPFrame(this);
       setVisible(true);
     
       }
     
     
     
     
     
     
     
     
     
           public void songGeter(File inputFile)
                { 
     
                  myDirectory = inputFile;
     
                  FileGeter dir1 = new FileGeter();
     
                  dir1.fileGet(myDirectory);
     
                  Thread myThread = new Thread(new RunClass(dir1));
     
                  myThread.start();
     
                }
     
     
     
    public class RunClass implements Runnable
    {
     
    FileGeter dir1;
     
     
     public RunClass(FileGeter dir)
    { 
     this.dir1 =dir;
    }
     
    public void run() {
     
                     Id3Tag tag1;
                     Collections.sort(dir1.bFiles, new Mp3Comparator()); // in the comparator the files that are sent to id3tag well show as is there's no tag because of the sorting -don't mind
     
                     if (!dir1.bFiles.isEmpty() ){  // if open
                            for (int h = 0 ; h < dir1.bFiles.size(); h++)
                             {
                             tag1 = new Id3Tag(dir1.bFiles.get(h)); 
     
                             setTextBox(tag1.getArtist());
     
                            }
                                                                                               }  //if close
                          else 
                          {
                           //System.out.println("no files "+myDirectory.exists());
                          }
                      }
     
     
     
     
     
     
     
     
    }
     
     
    public  void setTextBox(final String str)
          {
           SwingUtilities.invokeLater(new Runnable() {
                            public void run() 
                                        {
                                          textBox.append(str +'\n');
                                        }
     
                    });          
     
            }    
     
     
     
     
     
     
     
     
     
     
     
    public static void main(String[] args)
           {
             PFrame mainFrame = new PFrame();
     
     
           }
     
     
     
     
    }


    here is the listener too

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
     
     
     
     
    class ActListener implements ActionListener
    {
    JFileChooser myChooser = new JFileChooser();
    PFrame corrant;
     
          public void actionPerformed(ActionEvent event)
          {
     
     
            if (event.getActionCommand().equals("browse button"))
                {
     
                myChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                int retval = myChooser.showDialog(corrant, "OK");
     
                 if (retval == JFileChooser.APPROVE_OPTION)
                     {
                     File myDirectory = myChooser.getSelectedFile();
                     [B]corrant.songGeter(myDirectory);[/B]          
     
     
                     }
     
                 }
     
     
     
            }
     
     
     
            public void getPFrame (PFrame p)
               {
               [B]corrant = p;[/B]
               }
     
     
    }
    Last edited by mdstrauss; October 11th, 2009 at 04:51 PM.

  8. #6
    Junior Member
    Join Date
    Jul 2009
    Posts
    27
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Default Re: what is the

    got it i know know what the problem was, i am so stupid when i compiled the
    PFrame the was two extra class files that where compiled that i deleted because i thought
    that they where some error files, this now i noted that there class files of PFrame
    PFrame$1.class PFrame.class PFrame$RunClass.class


    sorry i just a biggener
    thank you

  9. #7
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: what is the

    Yeah when you have inner classes you get class files with dollar signs in them

    // Json

  10. The Following User Says Thank You to Json For This Useful Post:

    mdstrauss (October 12th, 2009)