Java JFrame Parent okToWriteFile(Frame parent, String fileName)

Here you can find the source of okToWriteFile(Frame parent, String fileName)

Description

ok To Write File

License

Open Source License

Declaration

public static boolean okToWriteFile(Frame parent, String fileName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;
import java.awt.*;

import java.io.*;

public class Main {
    public static boolean okToWriteFile(Frame parent, String fileName) {
        File f = new File(fileName);
        if (f.isDirectory()) {
            JOptionPane.showMessageDialog(parent, fileName
                    + " is a directory.", "Error!",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        } else if (f.exists()) {
            int saveAnswer = JOptionPane.showConfirmDialog(parent, "File "
                    + fileName/*from w w  w .j  a v a2s. c om*/
                    + " already exists.\nDo you want to overwrite?",
                    "Question", JOptionPane.OK_CANCEL_OPTION);
            return (saveAnswer == JOptionPane.OK_OPTION);
        }
        return true;
    }
}

Related

  1. getRootFrame(java.awt.Component c)
  2. getRootFrame(JComponent component)
  3. getSpssInstallationDirectory(Frame parent)
  4. installOperation(final RootPaneContainer frame, final int condition, final KeyStroke keyStroke, final String actionKey, Action action)
  5. isFrameModified(RootPaneContainer frame)
  6. oops(Frame parent, String s)
  7. rootFrame(@Nonnull Component component)
  8. runProgressDialog(Runnable runnable, Frame parentFrame, String title, int count)
  9. setFrameParentTitle(Container c, String s)