public javax.swing.Box.Filler from another package?

This page in the Java tutorial got me very confused with question 2d. Looking at the Java documentation here, it appears that the static nested class javax.swing.Box.AccessibleBox is protected, so it can be accessed in subclasses or in the same package; while the inner class javax.swing.Box.Filler has the default access modifier – package-protected, right? – so it can be accessed from the same package. However, just creating a simple class in a default Eclipse project:

package sandbox;
import javax.swing.Box;
public class ExternalClass {
    Box.Filler var1; // Fine?
    Box.AccessibleBox var2; // Compile error - not visible???
}

Why can I access Box.Filler; and if I can access that, then why can't I access Box.AccessibleBox, which, as protected, ought to be more visible than Box.Filler, which is package-protected?


It is static , but it is not protected . Javadocs omit the public modifier. If you look at the source, the complete class declaration for Filler is:

public static class Filler extends JComponent implements Accessible
链接地址: http://www.djcxy.com/p/24050.html

上一篇: Java实例变量可访问性

下一篇: 公共javax.swing.Box.Filler从另一个包?