java.awt.FileDialog#dispose ( )源码实例Demo

下面列出了java.awt.FileDialog#dispose ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码2 项目: TencentKona-8   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码3 项目: jdk8u60   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码4 项目: openjdk-jdk8u   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码6 项目: openjdk-jdk9   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码7 项目: jdk8u-jdk   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码8 项目: hottub   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码9 项目: openjdk-8-source   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码10 项目: openjdk-8   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码11 项目: jdk8u_jdk   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码12 项目: jdk8u-jdk   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}
 
源代码13 项目: jdk8u-dev-jdk   文件: PolicyTool.java
/**
 * perform SAVE AS
 */
void displaySaveAsDialog(int nextEvent) {

    // pop up a dialog box for the user to enter a filename.
    FileDialog fd = new FileDialog
            (tw, PolicyTool.getMessage("Save.As"), FileDialog.SAVE);
    fd.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            e.getWindow().setVisible(false);
        }
    });
    fd.setVisible(true);

    // see if the user hit cancel
    if (fd.getFile() == null ||
        fd.getFile().equals(""))
        return;

    // get the entered filename
    File saveAsFile = new File(fd.getDirectory(), fd.getFile());
    String filename = saveAsFile.getPath();
    fd.dispose();

    try {
        // save the policy entries to a file
        tool.savePolicy(filename);

        // display status
        MessageFormat form = new MessageFormat(PolicyTool.getMessage
                ("Policy.successfully.written.to.filename"));
        Object[] source = {filename};
        tw.displayStatusDialog(null, form.format(source));

        // display the new policy filename
        JTextField newFilename = (JTextField)tw.getComponent
                        (ToolWindow.MW_FILENAME_TEXTFIELD);
        newFilename.setText(filename);
        tw.setVisible(true);

        // now continue with the originally requested command
        // (QUIT, NEW, or OPEN)
        userSaveContinue(tool, tw, this, nextEvent);

    } catch (FileNotFoundException fnfe) {
        if (filename == null || filename.equals("")) {
            tw.displayErrorDialog(null, new FileNotFoundException
                        (PolicyTool.getMessage("null.filename")));
        } else {
            tw.displayErrorDialog(null, fnfe);
        }
    } catch (Exception ee) {
        tw.displayErrorDialog(null, ee);
    }
}