My apoologies (and thanks) to all who responded to my poorly formulated original
question in this thread.  I was in a hurry to leave town for the weekend and did a
much worse job than I had thought, of framing the issue.

In the first place, the code fragment should have shown both paint methods as
public as they were in my actual code.  In the second place, I didn't define the
problem as precisely as I might have.

The key point in this fragment is this: both a.java and b.java import java.awt.*.
As some have pointed out, since both reside in the same directory, strictly
speaking it is not necessary to #import a from b.  It in fact makes no difference
whether b imports a or not.  The key point is that all of a's methods tHat I call
from b are accepted **EXCEPT** those methods which have parameters that are defined
in java.awt; these are **NOT** recognized and rejected by the compiler.

A more meaningful code fragment would have been this:

//file a.java

import java.awt.*;

public class a {
   public void paint (Graphics g) {
      ...
   }
   public Point doSomethingWithAPoint (Point pt) {  // fails to compile
     pt.x += 7;
     return pt;
   }
   public int doSomethingWithAnInt( int i ) {

       return i + 2;
   }
}

//file b.java:
import java.awt.*;
import a;
public class b {
   public a A;
   ...
   b() {
    A = new a();
   }
   public void paint (Graphics g) {  // fails to compile
      A.paint(g);
   }

   public void doSomethingWithAPoint (Point pt) {  // fails to compile
      return A.doSomethingWithAPoint( pt );
   }
   public void doSomethingWithAnInt  (int i)   // compiler accepts.
        return A.doSomethingWithAnInt(i);
   }
}

The error message, by the way, is
"Method paint(java.awt.Graphics) not found in class a."

It almost seems as though the compiler thinks that the import of java.awt in a.java

has nothing to do with the import of the same class in b.java.   That is the
problem I was trying to get around.

Now that I have more properly defined the problem, are there any solutions?

Reply via email to