0

Every dialog window in SWT should extend the Dialog class, but I also have my own class View, that my dialogs also should extend.

OK, you should just make your View to extends Dialog, you can say. But the problem is, that my View shouldn't do it, because it also is used for classes, that aren't SWT dialogs.

Is there a way to overcome this problem?

reto
  • 9,995
  • 5
  • 53
  • 52
ovnia
  • 2,412
  • 4
  • 33
  • 54
  • Have you thought of refactoring your classes? Lets say: introducing a `DialogView` that extends `Dialog` – reto Dec 07 '13 at 20:27
  • @reto i had 2 AViewClasses: for SWT dialogs (extends Dialog) and SWT application view (extends nothing). But i decided to join them coz thay have 95% identical code, except constuctors and 1 method. – ovnia Dec 07 '13 at 20:31

1 Answers1

1
class ViewDialog extends Dialog {
    View view;
}

class DialogView extends View {
    Dialog diag;
}

Not everything has to extend. Not everything is another object. Some objects have other objects. A dialog can have a view that it displays or a view can have a dialog that displays it. If anything it doesn't really make sense for a dialog to also "be" the content that it displays.

Radiodef
  • 37,180
  • 14
  • 90
  • 125