I had been through this query before asking this question.

In class Window we have constructor with default direct access level package private but not private as shown below:

Window() throws HeadlessException {

With class dummy inheriting class Window,

import java.awt.*;

public class dummy extends Window{
    dummy() {


I see this error: Implicit super constructor Window() is not visible. Must explicitly invoke another constructor

I designed non-public class with zero-arg constructor having default direct access level package private and the subclass constructor invokes zero-arg Superclass constructor without any error.

I would like to understand,

Why does the compiler show this error despite the direct access level to the constructor Window(){} is package private?

Note: I am using jdk 1.6

1 Answer 1


For the same reason as in the linked question: the constructor is package-private. It cannot be accessed outside of the java.awt package, and I assume your class is not in that package.

In this case I have to wonder why you would be extending the Window class to begin with. In general, one should always use AWT and Swing by assembling standard components. It is fairly rare to be in a situation where it is necessary to create a subclass for any AWT or Swing class. Often it is a sign of using the frameworks incorrectly: for example, subclassing JFrame in order to set the frame's title in the constructor and to add components, when both actions are perfectly fine to perform in another class (create JFrame using the string constructor, call add() with subcomponents).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.