1

Why can't I add a constructor in class GroupLayout like:

public class xxx extends GroupLayout {

  public xxx(Container host, String...arg) {
    //code
  }
}
craigcaulfield
  • 3,381
  • 10
  • 32
  • 40

1 Answers1

0

GroupLayout doesn't have a no-argument constructor meaning Java can't make an implicit call to it's constructor, so you'd be getting a compile-time error about that. You just need to call super(host) as the first line of your method to invoke the constructor that GroupLayout does have. Try:

public class SubGroupLayout extends GroupLayout {

    public SubGroupLayout(Container host, String ...arg) {
        super(host);
        // then, do your own code here
    }
}

See Using the Keyword super and super() in constructor for more details.

craigcaulfield
  • 3,381
  • 10
  • 32
  • 40