Of the comments:
the error appears in'public String getType () {'appears as "getType () is ConnectDialog can not override getType () in Wondow return type String in not compatible with Type" and "Add Override Anotation"
They are two different things.
This comes because you are overwriting a method of the parent class (or, from Java 7, implementing a method of an interface).
The "Add Override Annotation" is just an advice; to make sure that "marks" for the compiler that the method implements a method of the parent / interface class 1 . It has nothing to do with the error.
The error is that, when implementing the method, you are doing it in a way that you define a return type that has nothing to do with the original method. For example, even the original method has a signature public int getType()
. As there is no automatic conversion possible from String
to int
, that definition does not allow 2 .
Solution: Make the return type match the one defined in the superclass / interface.
1 What this does is force the compiler to check that, indeed, the method exists in the superclass / interface. That way, if you change the signature of the method there, it warns you to change the subclass, or warns you if you have misspelled the signature.
2 If in the superclass / interface you had defined the method as public Object getType()
then there would be no error, since a String
is a subclass of Object
and you could assign the String
where getType()
is used.