⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myfilechooser.java

📁 java画图程序
💻 JAVA
字号:
package mypackage;
import javax.swing.*;
import java.io.File;
import javax.swing.filechooser.FileSystemView;

//保存对话框
public class MyFileChooser extends JFileChooser
{

    public MyFileChooser() 
    {
        super();
    }

    public MyFileChooser(File currentDirectory) 
    {
        super(currentDirectory);
    }

    public MyFileChooser(File currentDirectory, FileSystemView fsv) 
    {
        super(currentDirectory, fsv);
    }

    public MyFileChooser(FileSystemView fsv) 
    {
        super(fsv);
    }

    public MyFileChooser(String currentDirectoryPath) 
    {
        super(currentDirectoryPath);
    }

    public MyFileChooser(String currentDirectoryPath, FileSystemView fsv) 
    {
        super(currentDirectoryPath, fsv);
    }

    public void approveSelection()
    {
        if (this.getDialogType() == JFileChooser.SAVE_DIALOG)
        {
            File temp = this.getSelectedFile();
            
            if (temp.exists()) 
            {
                if (JOptionPane.showConfirmDialog(this,
                        temp.getPath() + " 已存在。\n要替换它吗?",
                        	"另存为",
                        		JOptionPane.YES_NO_OPTION,
                        			JOptionPane.WARNING_MESSAGE)
                        				== JOptionPane.NO_OPTION)
                    return;
            }
        }
        super.approveSelection();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -