Community
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

cannot find symbol [error]

 
Post new topic   Reply to topic    Community Forum Index -> Java
View previous topic :: View next topic  
Author Message
jon80



Joined: 28 May 2009
Posts: 24

PostPosted: Tue Sep 27, 2011 9:28 pm    Post subject: cannot find symbol [error] Reply with quote

Any idea why I get an error when compiling this code? I think it's a bug, because I declared the class within a sub-folder named musicrecord.

Code:


package musicrecord;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

/**
 * @version 1.0
 * @author Jon C.
 */
public class MusicCollectionUI
{
   public static void main(String[] args)
   {
      EventQueue.invokeLater(new Runnable()
         {
            public void run()
            {
               CheckBoxFrame frame = new CheckBoxFrame();
               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               frame.setVisible(true);
            }
         });
   }
}

/**
 * A frame with a sample text label and check boxes for selecting font attributes.
 */
class CheckBoxFrame extends JFrame
{
   public CheckBoxFrame()
   {
      setTitle("CheckBoxTest");
      setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

      // add the sample text label

      label = new JLabel("The quick brown fox jumps over the lazy dog.");
      label.setFont(new Font("Serif", Font.PLAIN, FONTSIZE));

     MusicRecord records = new MusicRecord();
     ArrayList<String> fields = new ArrayList<String>();
     fields.addAll(records.readFields(FILENAME, DELIMITER));

     int i = 0;
     String[] data = {};
     for (String f : fields)
     {
       data[i] = f;
       ++i;
     }

     JList myList = new JList(data);


      add(myList, BorderLayout.CENTER);

      JPanel buttonPanel = new JPanel();
      add(buttonPanel, BorderLayout.SOUTH);
   }

   public static final int DEFAULT_WIDTH = 300;
   public static final int DEFAULT_HEIGHT = 200;

   private JLabel label;
   private JCheckBox bold;
   private JCheckBox italic;

   private static final int FONTSIZE = 12;
   private static String FILENAME = "CATALOG.CSV";
   private static String DELIMITER = ",";
}


package musiccollection;

import java.io.*;
import java.util.*;
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConfigurator;

/**
 *
 * @author Jon
 * @version 1.0
 */
public class MusicRecord {
   
    public MusicRecord()
    {
        BasicConfigurator.configure();
    }
    public String getLocation ()
    {
        return this.Location;
    }
    public void setLocation(String location)
    {
        this.Location = location;
    }
   
    public String getTitle()
    {
        return this.Title;
    }
   
    public void setTitle(String title)
    {
        this.Title = title;
    }
   
    public String getAuthor()
    {
        return this.Author;
    }
   
    public void setAuthor (String author)
    {
        this.Author = author;
    }
   
    public String getPublisher()
    {
        return this.Publisher;
    }
   
    public void setPublisher(String publisher)
    {
        this.Publisher = publisher;
    }
   
    public double getPlayTime()
    {
        return PlayTime;
    }
   
    public void setPlayTime (Integer playtime)
    {
        /* playtime in number of seconds */
        this.PlayTime = playtime;
    }
   
    public void save(String fileName, String newFileContent) throws IOException
    {
        StringBuilder addContent = new StringBuilder();
        if (existingFileContent != null) addContent.append(existingFileContent);
        addContent.append(newFileContent);
        BufferedWriter out = new BufferedWriter(new FileWriter(fileName, true));
        out.write(addContent.toString());
        out.close();
        /* Sourced and adapted from http://zamov.online.fr/EXHTML/JAVA/JAVA_785340.html */
    }
   
    public ArrayList<String> readFields (String fileName, String delimiter) throws IOException
    {
      ArrayList<String> result = new ArrayList<String>();
      BufferedReader reader = new BufferedReader(new FileReader(fileName));
      String line = null;
      while ((line = reader.readLine()) != null)
      { 
          allFields.addAll(Arrays.asList(line.split(delimiter)));
      }
      reader.close();
      whichRecord = 0;
     
      result = allFields;
      return result;
     
    }
   
    public ArrayList<String> readNext()
    {
        ArrayList<String> result = new ArrayList<String>();
        if (whichRecord < allFields.size())
        {
            result.add(allFields.get(++whichRecord));
            errorLog.debug(allFields.get(++whichRecord));
            return result;
        }
        else
        {
            return null;
        }
       
    }
   
    public ArrayList<String> readPrevious()
    {
       ArrayList<String> result = new ArrayList<String>();
       if (whichRecord > 0)
               {
                    result.add(allFields.get(--whichRecord));
                    errorLog.debug(allFields.get(--whichRecord));
                    return result;
               }
       else
               {
                   return null;
               }
    }
   
   
   
    public enum MusicType {SOLO, COLLECTION}
    public static int whichRecord = 0;
    private String Location;
    private String Title;
    private String Author;
    private String Publisher;
    private Integer PlayTime;
    private String existingFileContent;
    private ArrayList<String> allFields = new ArrayList<String>();
   
    private static final Logger errorLog = Logger.getLogger(MusicRecord.class);
   
}



CATALOG.CSV
A5|Allegro Andante|Beethoven|EMI|0|300|A6|La Marcia Turca|Mozart|EMI|0|300|

Error
C:\Documents and Settings\Jon\Desktop\Nelly\musicrecord\MusicCollectionUI.java:43: cannot find symbol
symbol  : class MusicRecord
location: class musicrecord.CheckBoxFrame
     MusicRecord records = new MusicRecord();
     ^
C:\Documents and Settings\Jon\Desktop\Nelly\musicrecord\MusicCollectionUI.java:43: cannot find symbol
symbol  : class MusicRecord
location: class musicrecord.CheckBoxFrame
     MusicRecord records = new MusicRecord();


_________________
Jon
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
MudGuard



Joined: 02 Mar 2003
Posts: 1255
Location: Munich, Germany

PostPosted: Wed Sep 28, 2011 6:09 am    Post subject: Reply with quote

your class CheckboxFrame is in a different package (musiccollection). So without import or fully qualified class name, it is not visible for MusicCollectionUI in package musicrecord.

Btw, usually, package names (except for java's own packages) start with a top level domain, then the domain owned by the programmer/his company (as in org.apache.log4j which comes from apache.org ...)
Back to top
View user's profile Send private message Visit poster's website
jon80



Joined: 28 May 2009
Posts: 24

PostPosted: Wed Sep 28, 2011 3:10 pm    Post subject: Reply with quote

MudGuard wrote:
your class CheckboxFrame is in a different package (musiccollection). So without import or fully qualified class name, it is not visible for MusicCollectionUI in package musicrecord.

Btw, usually, package names (except for java's own packages) start with a top level domain, then the domain owned by the programmer/his company (as in org.apache.log4j which comes from apache.org ...)


Thanks for reminding me about the naming convention, this was just a quick fix Smile
_________________
Jon
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Community Forum Index -> Java All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB