Hi,
q1:
No, you cannot add a Window (so no Frame, no Dialog) to a container.
But I am wondering why, perhaps I was to fast but I didn't see that in the API documentation.
import java.awt.*;
public class A extends Panel
{
A()
{
add(new Frame("mamuba"));
}
public static void main(
String args[]) //2
{
A a = new A();
}
}
and this is what I have obtained at run time
Exception in
thread "main" java.lang.IllegalArgumentException: adding a window t
o a container
at java.awt.Container.addImpl(Unknown Source)
at java.awt.Container.add(Unknown Source)
at A.<init>(A.java:7)
at A.main(A.java:11)
q2.
Yes, I think that an anonymous class can extend an abstract class, check the following code:
class C
{
public static void doSomething(B b)
{
System.out.println("in c...");
}
}
abstract class B
{
abstract public void f();
}
public class A extends C
{
public static void main(String args[])
{
doSomething(
new B()
{
public void f()
{
System.out.println("bla");
}
}
);
}
}
..Cristian