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
...
Asked
Active
Viewed 173 times
2
1 Answers
2
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)

Java42
- 7,628
- 1
- 32
- 50
-
aaaa so that is the reason... interesting, couldn´t they also add a constructor for window ¬.¬, I need one of those :(... thanks for your answer :)... – Ordiel Mar 08 '13 at 17:45
-
@Ordiel - Create a new question concerning that need. But I think the answer is going to be FileDialog fd = new FileDialog(Frame(null)); (or new FileDialog(new Frame()) ) - both cause an application modal dialog to pop (in my quick test). But better to post the new question to see what others think. – Java42 Mar 08 '13 at 18:04