Set default saving extension with JFileChooser

后端 未结 5 1090
借酒劲吻你
借酒劲吻你 2021-02-07 10:12

I\'m trying to save a file using JFileChooser. However, I seem to be having some trouble with it. Here\'s my code:

    if (e.getSource() == saveMenu         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 10:40

    You should try this:

    if(!file.getName().contains(".")) file = new File(file.toString() + ".xml");
    

提交回复
热议问题