Question

Can someone please explain to me why does FileDialog implements two constructors, one for Frame and one for Dialog? I mean, why didn't they use the blessings of inheritance and just created a constructor using Window? I ask this because sometimes when you need to request a file using a GUI, you could request a file from a Frame or from a Dialog and it would be good if you don't have to worry about creating your "requester" method for a Frame and also for a Dialog, I took a look at the source code of FileDialog, and there is no difference (that I could appreciate) between the constructors, since they only use the Frame and Dialog to establish them as the parentComponent...

Était-ce utile?

La solution

Those constructions were created at different times in history. There is a strong, forcible need for backward compatibility.

// @since 1.5
public FileDialog(Dialog parent)

// @since JDK1.1
public FileDialog(Frame parent)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top