Trying to move inner class to a class file

Hi folks,
I keep getting an error which puzzles me. I cut the following class (MyDocumentListener) out of an outer class (CenterPanel).
MyDocumentListener compiles OK but...
Now when I compile the outerclass I get the folowing error:
C:\divelog> javac -classpath C:\ CenterPanel.java
CenterPanel.java:54: cannot access divelog.MyDocumentListener
bad class file: C:\divelog\MyDocumentListener.class
class file contains wrong class: MyDocumentListener
Please remove or make sure it appears in the correct subdirectory of the classpath.
MyDocumentListener myDocumentListener = new MyDocumentListener(); // define
the listener class
^
1 error
... yes I checked, it is there..
C:\divelog>dir m*.j*
Directory of C:\divelog
MYDOCU~1 JAV 936 03-04-03 11:16p MyDocumentListener.java
====================================================================
MyDocumentListener tests to see if the current document has changed.
Required fields: boolean documentWasChanged;
import javax.swing.event.*;
// ------ Document listener class -----------
public class MyDocumentListener implements DocumentListener {
public void insertUpdate(DocumentEvent e) {
wasChanged(e);
public void removeUpdate(DocumentEvent e) {
wasChanged(e);
public void changedUpdate(DocumentEvent e) {
public boolean wasChanged(DocumentEvent e) {
// indicate that the document was changed
//and test before opening another file or closing the application.
boolean documentWasChanged = true;
return documentWasChanged;
} // close class MyDocumentListener
====================================================================
package divelog;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
// import javax.swing.text.JTextComponent.*;
import javax.swing.text.*;
public class CenterPanel extends JPanel implements ActionListener
{ // Opens class
static private final String newline = "\n";
private JTextArea comments;
private JScrollPane scrollpane;
private JButton saveButton, openButton;
private JLabel whiteshark;
private Box box;
private BufferedReader br ;
private String str;
private JTextArea instruct;
private File defaultDirectory = new File("C://divelog");
private File fileDirectory = null;
private File currentFile= null;
// public boolean changed;
public boolean documentWasChanged;
public CenterPanel()
{ // open constructor CenterPanel
setBackground(Color.white);
comments = new JTextArea("Enter comments, such as " +
"location, water conditions, sea life you observed," +
" and problems you may have encountered.", 15, 10);
comments.setLineWrap(true);
comments.setWrapStyleWord(true);
comments.setEditable(true);
comments.setFont(new Font("Times-Roman", Font.PLAIN, 14));
// add a document listener for changes to the text,
// query before opening a new file to decide if we need to save changes.
MyDocumentListener myDocumentListener = new MyDocumentListener(); // define the listener class
comments.getDocument().addDocumentListener(myDocumentListener); // create the reference for the class
scrollpane = new JScrollPane(comments);
scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
saveButton = new JButton("Save Comments", new ImageIcon("images/Save16.gif"));
saveButton.addActionListener( this );
saveButton.setToolTipText("Click this button to save the current file.");
openButton = new JButton("Open File...", new ImageIcon("images/Open16.gif"));
openButton.addActionListener( this );
openButton.setToolTipText("Click this button to open a file.");
whiteshark = new JLabel("", new ImageIcon("images/gwhite.gif"), JLabel.CENTER);
Box boxH;
boxH = Box.createHorizontalBox();
boxH.add(openButton);
boxH.add(Box.createHorizontalStrut(15));
boxH.add(saveButton);
box = Box.createVerticalBox();
box.add(scrollpane);
box.add(Box.createVerticalStrut(10));
box.add(boxH);
box.add(Box.createVerticalStrut(15));
box.add(whiteshark);
add(box);
} // closes constructor CenterPanel
public void actionPerformed( ActionEvent evt )
{ // open method actionPerformed
// --------- test to see if the current file was modified and give an option to save first.
if (documentWasChanged) // add and IF filename not null
// ----- display pop-up alert --------------------------------------------------------------
int confirm = JOptionPane.showConfirmDialog(null,
"Click OK to discard current changes, \n or Cancel to save before proceeding.", // msg
"Unsaved Modifications!", // title
JOptionPane.OK_CANCEL_OPTION, // buttons displayed
// JOptionPane.ERROR_MESSAGE
// JOptionPane.INFORMATION_MESSAGE
// JOptionPane.PLAIN_MESSAGE
// JOptionPane.QUESTION_MESSAGE
JOptionPane.WARNING_MESSAGE,
null);
if (confirm != JOptionPane.YES_OPTION) //user wants to save changes
try {
// let user save the file
catch(Exception e) {}
else // let user open a new file
} // close "if (documentWasChanged)" - display pop-up alert ----------
JFileChooser jfc = new JFileChooser();
     //Add a custom file filter and disable the default "Accept All" file filter.
jfc.addChoosableFileFilter(new JTFilter()); // /** found in Utils.java /*
jfc.setAcceptAllFileFilterUsed(false);
// -- open the default directory --
// public void setCurrentDirectory(File dir)
// jfc.setCurrentDirectory(new File("C://divelog"));
jfc.setCurrentDirectory(defaultDirectory);
jfc.setSize(400, 300);
jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
Container parent = saveButton.getParent();
//========================= Test Button Actions ================================
//========================= Open Button ================================
if (evt.getSource() == openButton)
int choice = jfc.showOpenDialog(CenterPanel.this);
File file = jfc.getSelectedFile();
// --------- change test was here -----------
/* a: */
if (file != null && choice == JFileChooser.APPROVE_OPTION)
String filename = jfc.getSelectedFile().getAbsolutePath();
// -- get the current directory name -------
// public File getCurrentDirectory( );
File f=new File(System.getProperty("user.dir"));
fileDirectory = jfc.getCurrentDirectory();
// -- remember the last directory used --
if (defaultDirectory != fileDirectory)
{defaultDirectory = fileDirectory;}
try
{ //opens try         
comments.getLineCount( );
// -- clear the old data before importing the new file --
comments.selectAll();
comments.replaceSelection("");
// -- get the new data ---
br = new BufferedReader (new FileReader(file));
while ((str = br.readLine()) != null)
{//opens while
comments.append(str);
} //closes while
} // close try
catch (IOException ioe)
{ // open catch
comments.append(newline +"Open command not successful:" + ioe + newline);
} // close catch
// ---- display the values of the directory variables -----------------------
comments.append(
newline + "The f directory variable contains: " + f +
newline + "The fileDirectory variable contains: " + fileDirectory +
newline + "The defaultDirectory variable contains: " + defaultDirectory );
else
comments.append("Open command cancelled by user." + newline);
} //close if statement /* a: */
//========================= Save Button ================================
} else if (evt.getSource() == saveButton)
int choice = jfc.showSaveDialog(CenterPanel.this);
if (choice == JFileChooser.APPROVE_OPTION)
File fileName = jfc.getSelectedFile();
// -- get the current directory name -------
// public File getCurrentDirectory( );
File f=new File(System.getProperty("user.dir"));
fileDirectory = jfc.getCurrentDirectory();
// -- remember the last directory used --
if (defaultDirectory != fileDirectory)
{defaultDirectory = fileDirectory;}
//check for existing files. Warn users & ask if they want to overwrite
for(int i = 0; i < fileName.length(); i ++) {
File tmp = null;
tmp = (fileName);
if (tmp.exists()) // display pop-up alert
//public static int showConfirmDialog( Component parentComponent,
// Object message,
// String title,
// int optionType,
// int messageType,
// Icon icon);
int confirm = JOptionPane.showConfirmDialog(null,
fileName + " already exists on " + fileDirectory
+ "\n \nContinue?", // msg
"Warning! Overwrite File!", // title
JOptionPane.OK_CANCEL_OPTION, // buttons displayed
                    // JOptionPane.ERROR_MESSAGE
                    // JOptionPane.INFORMATION_MESSAGE
                    // JOptionPane.PLAIN_MESSAGE
                    // JOptionPane.QUESTION_MESSAGE
JOptionPane.WARNING_MESSAGE,
null);
if (confirm != JOptionPane.YES_OPTION)
{ //user cancels the file overwrite.
try {
jfc.cancelSelection();
break;
catch(Exception e) {}
// ----- Save the file if everything is OK ----------------------------
try
{ // opens try
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
bw.write(comments.getText());
bw.flush();
bw.close();
comments.append( newline + newline + "Saving: " + fileName.getName() + "." + newline);
break;
} // closes try
catch (IOException ioe)
{ // open catch
comments.append(newline +"Save command unsuccessful:" + ioe + newline);
} // close catch
} // if exists
} //close for loop
else
comments.append(newline + "Save command cancelled by user." + newline);
// ========= }
} // end-if save button
} // close method actionPerformed
} //close constructor CenterPanel
// <<<<<<<<<<<<<<<<<
// <<<<<<<<<<<<<<<<< MyDocumentListener class was here <<<<<<<<<<<<<<<<<
// <<<<<<<<<<<<<<<<<
} // Closes class CenterPanel

You didn't put your MyDocumentListener class in the package divelog.
Add
package divelog;to the top of MyDocumentListener.java and recompile.

Similar Messages

  • Error 36 when trying to move copy or compress a .mpg file

    Error 36 when trying to move, copy or compress a large .mpg file (32gb!)
    please help I have tried everything on Google (dot_clean/safe mode etc) need help!

    BDAqua wrote:
    I hear 3rd Party, or HW Raid 0/1/5/10 are OK, but 6 months is the absolute most I got out of my many screaming RAID setups before they completely lost it!
    Bummer. I'm not really doing this for speed though, just for total storage volume and constant, worry-free, no-brainer back-up. I guess RIAD in general is something I need to study up on. Would a simple mirror of one 500GB drive to another (back-up) - and do that twice - be a better, more reliable way to go?
    I've used Tri-Backup3/4 for years for Backups, it's fast, automatic, reliable, works in the background if you wish...
    Back-up software always seemed to have some kind of a hiccup to it, but I'll certainly look into Tri-Backup3/4. I used to Retrospect years ago, a rather fussy thing if I recall.
    Now, on the Safe Mode boot - not a success BUT a different result!
    I got the -36 again, but this time it was the external drive FILE that errored, not the OS-resident drive.
    In other words, pre-Safe Mode the error said "...because some data in "ZillaHAL" could not be read or written." (ZillaHAL is my OS-X drive).
    In Safe, it read, "...because some data in "WinXP Pro.vmem" could not be read or written."
    "WinXP Pro.vmem" is the virtual machine file - which basically is a simple Mac volume (folder) containing all of the files to run my XP virtual machine.
    Also, this time, a file* did manage to remain on the external drive whereas before, after the error, no file at all remained.
    * a generic icon appears, but it shows a size of 16+GBs. The actual file is 18.13GB - I did manage to shrink it down the other day (from it's previous 25GB).
    Well, that's it for now. I'll be away for three days, so don't mind me if I cannot reply back for a spell.
    Thanks BD,
    mp

  • I am trying to move my Elements 9 catalog and files from Windows 7 to Mac OSX Yosemite and can't connect the files on the Mac.

    When I try to connect the files to the catalog on the Mac, many (~9000 out of ~12000) files show as can not reconnect. Elements finds "similar" files (actually the files I want) but says they are not the same file. I noticed that many of them have the time parameter different in the file compared to the catalog. If I go ahead and say reconnect anyway, I get another error indicating the the data has been changed by two different sources. If offers the choice of overwriting the file data with info from the catalog (which loses the EXIF data in the file) or says leave the file alone (which loses the keyword metadata from the catalog). Is there any way to get Elements to connect all of these files while retaining all of the EXIF and the keyword metadata without having to re-edit or re-import each of these files? My ultimate aim is to then move all of these photos into the current version of Lightroom on the Mac.

    You won't like this response, but there is no way to simply move any Adobe software installation from one system to another. In part, this has to do with the registration/activation infrastructure that Adobe uses. FWIW, Adobe isn't the only software vendor for which you can't simply move software from one system to another via various migration tools.
    You must totally uninstall from the first system including product deactivation and then install on the new system and reactivate.
    In terms of “fixing” your current system, I would recommend totally uninstalling the software (and deactivating in the process), reboot, and then reinstall from scratch.
              - Dov

  • Trying to serialize inner class and getting various errors.

    Hi, I'm working on a program that contains the inner class User. user implements serializable, and writes just fine. For some strange reason, though, after I read it, I keep getting NullPointerExceptions in my code.
    I also tried it using externalization. The User class is essentially built around a HashMap. I have the following methods:
    public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(mainMap);
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    mainMap = (Map) in.readObject();
    String test = (String) in.readObject();
    Whenever inputstream.readObject() is called, though, I get an InvalidClassException; "no valid constructor." The sad part is that I have the method:
    public User () {
    main = new HashMap();
    Does anyone know what the problem is??? Thanks a lot!

    Does anyone know what the problem is???The inner class is not a static inner class. Therefore your constructor User, is actually User(OuterClass). Solution - make the class static OR use read and/or write resolution to reconstruct the relationship.

  • [svn] 4600: Flex SDK - Move style metadata from base class down to component classes

    Revision: 4600
    Author: [email protected]
    Date: 2009-01-20 13:11:33 -0800 (Tue, 20 Jan 2009)
    Log Message:
    Flex SDK - Move style metadata from base class down to component classes
    Previously, all spark and text styles were defined on FxComponent even though not every component supports all of those styles. So I have moved each style to the top-most base class where the style will apply to all descendant classes of that base class.
    This is the set of styles that were added to the various classes:
    baseColor
    color
    focusColor
    symbolColor
    selectionColor
    contentBackgroundColor
    rollOverColor
    alternatingItemColors
    basic text styles
    advanced text styles
    Here are some details about the implementation:
    - baseColor was added to FxComponent because every component and container supports it
    - FxContainer and GroupBase are containers, so their children can potentially support any of the styles. Thus the container classes support all of the styles indirectly.
    - FxDataContainer doesn't support all of the styles because its subclasses (FxButtonBar, FxList) don't support all styles.
    - FxList supports selectionColor, but not inactiveSelectionColor or unfocusedSelectionColor. All other components that support selectionColor, support the other two styles, and thus include styles/metadata/SelectionFormatTextStyles.as
    - GroupBase contains the style declarations that have the full ASDoc. All other declarations use the @copy keyword to reference the asdoc from GroupBase.
    QE Notes: Update tests to remove references to styles that are no longer allowed on various components/FxButton.as
    Doc Notes: Write the ASDoc comments for the style declarations in GroupBase
    Bugs: n/a
    Reviewer: Glenn
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxButton.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxCheckBox.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxContainer.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxDataContainer.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxList.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxNumericStepper.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxRadioButton.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxScroller.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxSpinner.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/FxTextArea.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/baseClasses/FxComponent.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/baseClasses/FxScrollBar.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/baseClasses/FxSlider.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/baseClasses/FxTextBase.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/components/baseClasses/GroupBase.as

    Gordon, it looks like its been a while since you made this post.  Not sure how valid it is now...   I am particularly interested in the LigatureLevel.NONE value.  It seems that it is no longer supported.
    How do I turn of ligatures in the font rendering?
    My flex project involves trying to match the font rendering of Apache's Batik rendering of SVG and ligatures have been turned off in that codebase.  Is there any way (even roundabout) to turn ligatures off in flash?
    Thanks,
    Om

  • How  to include the inner classes in a jar file in netbeans ide

    Dear java friends
    how to say to netbeans ide that it has to include the
    inner classes in the jar file.
    (i have one single applet class
    with two inner classes that show up
    in the build/classes file but not in the jar).
    The applet works in the viewer but not
    in the browser (I believe because the
    xxx$yyy etc should be in the jar)
    willemjav

    First, please stop posting the same question multiple times:
    Duplicate of http://forum.java.sun.com/thread.jspa?threadID=5269782&messageID=10127496#10127496
    with an answer.
    Second, If your problem is that you can't do this in NetBeans, you need to post to somewhere that provides NetBeans support - like the NetBeans website's mailing list. These forums do not support NetBeans (or any other IDE) - they are Java language forums.

  • Calling functions of the inner class in .java code file

    Hello,
    I created a .java code file in Visual J#.Net and converted it into
    the application by adding the "public static void main(String args[])"
    function.
    I have created the two classes one extends from Applet, and the other
    extends from Frame. The class which I inherited from the Frame class becomes
    the inner class of the class extended from the Applet. Now How do I
    call the functions of the class extended from Frame class - MenuBarFrame
    class. the outline code is
    public class menu_show extends Applet
    ------init , paint action function---------
    public class MenuBarFrame extends Frame
    paint,action function for Menu
    public static void main(String args[])
    applet class instance is created
    instance of frame is created
    Menu , MenuBar, MenuItem instance is created
    and all these objects added
    I have Created MenuBarFrame class instance as
    Object x= new menu_show().new MenuBarFrame
    ????? How to call the functions such as action of MenuBarFrame class - what
    should be its parameters??????
    }

    Here's how I would do it:
    interface Operation {
        public int op(int y);
    class X {
        private int x;
        public X(int x) {
            this.x = x;
        private class Y implements Operation {
            public int op(int y) {
                return x+y;
        public Operation createOperation() {
            return new Y();
        public static void main(String[] args) {
            X app = new X(17);
            Operation f = app.createOperation();
            System.out.println(f.op(-11));
    }Your code, however, has some serious "issues". You typically don't
    instantiate an applet class -- that's the job of the applet viewer or Java plugin
    your browser is using. If you instantiate the applet directly, you're going
    to have to supply it an AppletStub. Do you really want to go that way?
    Again, use an applet viewer or browser, or better yet, why write applets at all?

  • Trying to create an array of a class

    This is the first time ive tried to use an array so its not surprising im having trouble.
    this is my program:
    import java.util.*;
    public class studentRecordDemo
         public static void main(String[] args)
              int studNum, index;
              System.out.println("Enter the number of students you wish to record");
              Scanner keyboard = new Scanner(System.in);
              studNum = keyboard.nextInt();
              studentRecord student[] = new studentRecord[studNum];
              for (index = 0; index < studNum; index++)
              {student[index].readInput();
              student[index].writeOutput();}
    }And it lets me compile it but when i enter a number it gives me the error:
    Exception in thread "main" java.lang.NullPointerException
    at studentRecordDemo.main(studentRecordDemo.java:15)the
    So yeah im trying to create an array of the class "studentRecord" and the number is input by the user. Is there a way to make that work or would it be easier to just make the array a really high number?

    your error is in here:
    student[index].readInput();its null...
    This is the first time ive tried to use an array so
    its not surprising im having trouble.
    this is my program:
    import java.util.*;
    public class studentRecordDemo
         public static void main(String[] args)
              int studNum, index;
    System.out.println("Enter the number of students
    ts you wish to record");
              Scanner keyboard = new Scanner(System.in);
              studNum = keyboard.nextInt();
    studentRecord student[] = new
    ew studentRecord[studNum];
              for (index = 0; index < studNum; index++)
              {student[index].readInput();
              student[index].writeOutput();}
    }And it lets me compile it but when i enter a number
    it gives me the error:
    Exception in thread "main"
    java.lang.NullPointerException
    at
    studentRecordDemo.main(studentRecordDemo.java:15)the
    So yeah im trying to create an array of the class
    "studentRecord" and the number is input by the user.
    Is there a way to make that work or would it be
    easier to just make the array a really high number?

  • Getting error in VS while trying to include boss class in  resource (.fr) file

    Hi
    I am trying to include a boss class in my resource file but I am getting the below error while trying to build my project.
    error R32691: # Error: Custom type name expected, but 'kGTTxtEdtResponderServiceBoss' found.
    Any one faced such issue before?

    Hello kapoor_aman27,
    you must define the boss id in your *ID.h file and include the *ID.h in the .fr file.
    Markus

  • I am trying to watch an on-line video class and "missing plug-in" is displayed. Help!

    I am trying to watch an on-line video class and "missing plug-in" is displayed. Help!

    More information. What web site? Provide a link.

  • Distributing classes over various source files

    Hi,
    Here are my 2 newbie java questions about :
    1) is it possible to split a single class up among several files,? I�ve tried taking my file foo.java and splitting it so that half the methods are in foo1.java and the other half are in foo2.java, just for convinience and readablity. Javac doesn't seem to like this. Is there something I shoudl be doing to make this legal or is it just not allowed?
    2) Similarly, is there a way have a private inner class in a seperate file from its outer class?
    I haven�t seen any references to how to do this � is it that javac is very dependant on the structure of the .java files, or just that all the examples I�ve seen so far have been?
    Thanks,
    Dan

    1) is it possible to split a single class up among several files,? Yes, but you'll have to glue them all back together again to get javac to process them.
    I�ve tried taking my file foo.java
    and splitting it so that half the methods are in foo1.java and the other half are in foo2.java,
    just for convinience and readablity. Convinience : doesn't seem very convenient to me to have one class split into two source files.
    Readability: as above, less readable.
    If your class seems incovenient or unreadable, its most likely too big and doing too many things.
    Javac doesn't seem to like this. Is there something I
    shoudl be doing to make this legal or is it just not allowed?Glueing the pieces back together.
    2) Similarly, is there a way have a private inner class in a seperate file from its outer class?Not without some preprocessor goo.
    is it that javac is very dependant on the structure of the .java filesMost likely by design.

  • How do I convert Wallet.class to a CAP file?

    I was trying to convert one of the sample files( Wallet.class) to a CAP file but it didn't work.
    Please help!!!

    Please be more specific. Describe what you did in detail, provide outputs of your actions etc. Otherwise noone can help you.
    Somebody save the world..

  • How to create java classes when multiple xsd files with same root element

    Hi,
    I got below error
    12/08/09 16:26:38 BST: [ERROR] Error while parsing schema(s).Location []. 'resultClass' is already defined
    12/08/09 16:26:38 BST: [ERROR] Error while parsing schema(s).Location []. (related to above error) the first definition appears here
    12/08/09 16:26:38 BST: Build errors for viafrance; org.apache.maven.lifecycle.LifecycleExecutionException: Internal error in the plugin manager executing goal 'org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.7.1:generate': Mojo execution failed.
    I tried genarate java classes from multiple xsd files, but getting above error, here in .xsd file i have the <xe: element="resultClass"> in all .xsd files.
    So I removed all .xsd files accept one, now genarated java classes correctly. but i want to genarte the java classes with diffrent names with out changing .xsd
    Can you please tell me any one how to resolve this one......
    regards
    prasad.nadendla

    Gregory:
    If you want to upload several Java classes in one script the solution is .sql file, for example:
    set define ?
    create or replace and compile java source named "my.Sleep" as
    package my;
    import java.lang.Thread;
    public class Sleep {
    public static void main(String []args) throws java.lang.InterruptedException {
    if (args != null && args.length>0) {
    int s = Integer.parseInt(args[0]);
    Thread.sleep(s*1000);
    } else
    Thread.sleep(1000);
    create or replace and compile java source named "my.App" as
    package my;
    public class App {
    public static void main(String []args) throws java.lang.InterruptedException {
    System.out.println(args[0]);
    exit
    Then the .sql file can be parsed using the SQLPlus, JDeveloper or SQLDeveloper tools.
    HTH, Marcelo.

  • How to put multiple classes in a single file?

    Hello,
    I'd like to put mutliple classes in a single file. (This
    would be useful for grouping children that are minor extensions of
    parent classes or helper classes that are used by one class only).
    When I tried to put two classes in one file, I got this error
    message:
    5006: An ActionScript file can not have more than one
    externally visible definition: Notation.editField,
    Notation.labelField1
    This is the structure I used. Thanks in advance for your
    help.

    You can declare multiple classes in a single file, but only
    one can be
    within the package declaration. All class declarations
    outside the package
    are invisible to code outside the file.
    package sample
    public class SampleClass
    class SampleClassHelper
    class SampleClassHelper2

  • Passing a parameter from one class to another class in the same package

    Hi.
    I am trying to pass a parameter from one class to another class with in a package.And i am Getting the variable as null every time.In the code there is two classes.
    i. BugWatcherAction.java
    ii.BugWatcherRefreshAction.Java.
    We have implemented caching in the front-end level.But according to the business logic we need to clear the cache and again have to access the database after some actions are happened.There are another class file called BugwatcherPortletContent.java.
    So, we are dealing with three java files.The database interaction is taken care by the portletContent.java file.Below I am giving the code for the perticular function in the bugwatcherPortletContent.java:
    ==============================================================
    public Object loadContent() throws Exception {
    Hashtable htStore = new Hashtable();
    JetspeedRunData rundata = this.getInputData();
    String pId = this.getPorletId();
    PortalLogger.logDebug(" in the portlet content: "+pId);
    pId1=pId;//done by sraha
    htStore.put("PortletId", pId);
    htStore.put("BW_HOME_URL",CommonUtil.getMessage("BW.Home.Url"));
    htStore.put("BW_BUGVIEW_URL",CommonUtil.getMessage("BW.BugView.Url"));
    HttpServletRequest request = rundata.getRequest();
    PortalLogger.logDebug(
    "BugWatcherPortletContent:: build normal context");
    HttpSession session = null;
    int bugProfileId = 0;
    Hashtable bugProfiles = null;
    Hashtable bugData = null;
    boolean fetchProfiles = false;
    try {
    session = request.getSession(true);
    // Attempting to get the profiles from the session.
    //If the profiles are not present in the session, then they would have to be
    // obtained from the database.
    bugProfiles = (Hashtable) session.getAttribute("Profiles");
    //Getting the selected bug profile id.
    String bugProfileIdObj = request.getParameter("bugProfile" + pId);
    // Getting the logged in user
    String userId = request.getRemoteUser();
    if (bugProfiles == null) {
    fetchProfiles = true;
    if (bugProfileIdObj == null) {
    // setting the bugprofile id as -1 indicates "all profiles" is selected
    bugProfileIdObj =(String) session.getAttribute("bugProfileId" + pId);
    if (bugProfileIdObj == null) {
    bugProfileId = -1;
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    session.setAttribute(
    ("bugProfileId" + pId),
    Integer.toString(bugProfileId));
    //fetching the bug list
    bugData =BugWatcherAPI.getbugList(userId, bugProfileId, fetchProfiles);
    PortalLogger.logDebug("BugWatcherPortletContent:: got bug data");
    if (bugData != null) {
    Hashtable htProfiles = (Hashtable) bugData.get("Profiles");
    } else {
    htStore.put("NoProfiles", "Y");
    } catch (CodedPortalException e) {
    htStore.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    PortalLogger.logException
    ("BugWatcherPortletContent:: CodedPortalException!!",e);
    } catch (Exception e) {
    PortalLogger.logException(
    "BugWatcherPortletContent::Generic Exception!!",e);
    htStore.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.GET_BUGLIST_FAILED));
    if (fetchProfiles) {
    bugProfiles = (Hashtable) bugData.get("Profiles");
    session.setAttribute("Profiles", bugProfiles);
    // putting the stuff in the context
    htStore.put("Profiles", bugProfiles);
    htStore.put("SelectedProfile", new Integer(bugProfileId));
    htStore.put("bugs", (ArrayList) bugData.get("Bugs"));
    return htStore;
    =============================================================
    And I am trying to call this function as it can capable of fetching the data from the database by "getbugProfiles".
    In the new class bugWatcherRefreshAction.java I have coded a part of code which actually clears the caching.Below I am giving the required part of the code:
    =============================================================
    public void doPerform(RunData rundata, Context context,String str) throws Exception {
    JetspeedRunData data = (JetspeedRunData) rundata;
    HttpServletRequest request = null;
    //PortletConfig pc = portlet.getPortletConfig();
    //String userId = request.getRemoteUser();
    /*String userId = ((JetspeedUser)rundata.getUser()).getUserName();//sraha on 1/4/05
    String pId = request.getParameter("PortletId");
    PortalLogger.logDebug("just after pId " +pId);  */
    //Calling the variable holding the value of portlet id from BugWatcherAction.java
    //We are getting the portlet id here , through a variable from BugWatcherAction.java
    /*BugWatcherPortletContent bgAct = new BugWatcherPortletContent();
    String portletID = bgAct.pId1;
    PortalLogger.logDebug("got the portlet ID in bugwatcherRefreshAction:---sraha"+portletID);*/
    // updating the bug groups
    Hashtable result = new Hashtable();
    try {
    request = data.getRequest();
    String userId = ((JetspeedUser)data.getUser()).getUserName();//sraha on 1/4/05
    //String pId = (String)request.getParameter("portletId");
    //String pId = pc.getPorletId();
    PortalLogger.logDebug("just after pId " +pId);
    PortalLogger.logDebug("after getting the pId-----sraha");
    result =BugWatcherAPI.getbugList(profileId, userId);
    PortalLogger.logDebug("select the new bug groups:: select is done ");
    context.put("SelectedbugGroups", profileId);
    //start clearing the cache
    ContentCacheContext cacheContext = getCacheContext(rundata);
    PortalLogger.logDebug("listBugWatcher Caching - removing markup content - before removecontent");
    // remove the markup content from cache.
    PortletContentCache.removeContent(cacheContext);
    PortalLogger.logDebug("listBugWatcher Caching-removing markup content - after removecontent");
    //remove the backend content from cache
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(((JetspeedUser)data.getUser()).getUserName()));
    PortalLogger.logDebug("listBugWatcher Caching User: " +((JetspeedUser)data.getUser()).getUserName());
    PortalLogger.logDebug("listBugWatcher Caching pId: " +pId);
    if (pdata != null)
    // User's data found in cache!
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null");
    pdata.removeObject(PortletCacheHelper.getUserPortletHandle(((JetspeedUser)data.getUser()).getUserName(),pId));
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null- after removeObject");
    PortalLogger.logDebug("listBugWatcher Caching -finish calling the remove content code");
    //end clearing the cache
    // after clearing the caching calling the data from the database taking a fn from the portletContent.java
    PortalLogger.logDebug("after clearing cache---sraha");
    BugWatcherPortletContent bugwatchportcont = new BugWatcherPortletContent();
    Hashtable httable= new Hashtable();
    httable=(Hashtable)bugwatchportcont.loadContent();
    PortalLogger.logDebug("after making the type casting-----sraha");
    Set storeKeySet = httable.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, httable.get(paramName));
    PortalLogger.logDebug("after calling the databs data from hashtable---sraha");
    } catch (CodedPortalException e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    catch (Exception e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.EXCEPTION_CODE));
    try {
    ((JetspeedRunData) data).setCustomized(null);
    if (((JetspeedRunData) data).getCustomized() == null)
    ActionLoader.getInstance().exec(data,"controls.EndCustomize");
    catch (Exception e)
    PortalLogger.logException("bugwatcherRefreshAction", e);
    ===============================================================
    In the bugwatcher Action there is another function called PostLoadContent.java
    here though i have found the portlet Id but unable to fetch that in the bugWatcherRefreshAction.java . I am also giving the code of that function under the bugWatcherAction.Java
    ================================================
    // Get the PortletData object from intermediate store.
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(
    //rundata.getRequest().getRemoteUser()));
    ((JetspeedUser)rundata.getUser()).getUserName()));
    pId1 = (String)portlet.getID();
    PortalLogger.logDebug("in the bugwatcher action:"+pId1);
    try {
    Hashtable htStore = null;
    // if PortletData is available in store, get current portlet's data from it.
    if (pdata != null) {
    htStore =(Hashtable) pdata.getObject(     PortletCacheHelper.getUserPortletHandle(
    ((JetspeedUser)rundata.getUser()).getUserName(),portlet.getID()));
    //Loop through the hashtable and put its elements in context
    Set storeKeySet = htStore.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, htStore.get(paramName));
    bugwatcherRefreshAction bRefAc = new bugwatcherRefreshAction();
    bRefAc.doPerform(pdata,context,pId1);
    =============================================================
    So this is the total scenario for the fetching the data , after clearing the cache and display that in the portal.I am unable to do that.Presently it is still fetching the data from the cache and it is not going to the database.Even the portlet Id is returning as null.
    I am unable to implement that thing.
    If you have any insight about this thing, that would be great .As it is very urgent a promt response will highly appreciated.Please send me any pointers or any issues for this I am unable to do that.
    Please let me know as early as possible.
    Thanks and regards,
    Santanu Raha.

    Have you run it in a debugger? That will show you exactly what is happening and why.

Maybe you are looking for