Error when declaring java.awt.FileDialog

后端 未结 1 671
失恋的感觉
失恋的感觉 2021-01-21 12:29

I\'m trying to declare a java.awt.FileDialog in my code:

FileDialog save = new FileDialog(null, \"Save file\", FileDialog.SAVE);

But I get the

相关标签:
1条回答
  • 2021-01-21 13:10

    There are 2 constructors for FileDialog with 3 arguments. Because you passed null as the first argument, the compiler cannot distinguish which constructor you want.

    FileDialog(Dialog parent, String title, int mode)
    

    and

    FileDialog(Frame parent, String title, int mode)
    

    You could use:

    Frame frame = null;
    FileDialog save = new FileDialog(frame, "Save file", FileDialog.SAVE);
    

    to fix.

    0 讨论(0)
提交回复
热议问题