user3110458
user3110458

Reputation: 374

extending Widget, passing Parameter?

I extended a Widget, but how can i pass constructor vars to it :

    public class MenuBarNav extends MenuBar{

      public MenuBarNav() {
            this(true);

      }

    public MenuBarNav(boolean b) {


    }   

}

and then ;

MenuBarNav ksw = new MenuBarNav(true);

Normaly it is :

MenuBar test = new MenuBar(true);

and it shows me the Menu vertical.

do i have to extend it as Composite `?

Upvotes: 0

Views: 30

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64541

As a rule of thumb, you shouldn't extend widgets and should instead compose widgets (within a Composite).

In your specific case of why it doesn't work and how to make it work, Java 101:

public MenuBarNav(boolean b) {
  super(b);
}

Upvotes: 2

Related Questions