Java Code Examples for javax.swing.JFileChooser.OPEN_DIALOG

The following are Jave code examples for showing how to use OPEN_DIALOG of the javax.swing.JFileChooser class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: java-course   File: FIleFactory.java   Source Code and License Vote up 6 votes
/**
 * Opens a .jvd file, parse it and fill given drawing model with elements
 * from opened file.
 * 
 * @param model
 *            Drawing model.
 * @param frame
 *            Parent frame.
 * @return Opened file.
 */
public static File openJVDFile(DrawingModel model, JVDraw frame) {
    JFileChooser fc = new JFileChooser("./");
    fc.setAcceptAllFileFilterUsed(false);
    fc.addChoosableFileFilter(new FileNameExtensionFilter(".jvd", "jvd"));
    int status = fc.showOpenDialog(frame);
    if (status == JFileChooser.OPEN_DIALOG) {
        File file = fc.getSelectedFile();
        if (!Files.isRegularFile(file.toPath())) {
            return null;
        }
        model.clear();
        readJVDFile(file, model);
        return file;
    }
    return null;
}
 
Example 2
Project: rapidminer   File: FileChooserUI.java   Source Code and License Vote up 5 votes
private Icon getApproveButtonIcon(JFileChooser fc) {
	if (fc.getDialogType() == JFileChooser.OPEN_DIALOG) {
		return FILECHOOSER_OPEN_ICON;
	}
	if (fc.getDialogType() == JFileChooser.SAVE_DIALOG) {
		return FILECHOOSER_SAVE_ICON;
	}
	if (fc.getDialogType() == JFileChooser.CUSTOM_DIALOG) {
		return FILECHOOSER_SELECT_ICON;
	}
	return FILECHOOSER_SELECT_ICON;
}
 
Example 3
Project: java-course   File: FIleFactory.java   Source Code and License Vote up 5 votes
/**
 * Opens a file from disk.
 * 
 * @param frame
 *            Parent frame.
 * @return Opened file.
 */
public static File getFile(JVDraw frame) {
    JFileChooser fc = new JFileChooser("./");
    fc.setAcceptAllFileFilterUsed(false);
    fc.addChoosableFileFilter(new FileNameExtensionFilter(".jvd", "jvd"));
    int status = fc.showSaveDialog(frame);

    if (status == JFileChooser.OPEN_DIALOG) {
        return setExtension(fc.getSelectedFile(), ".jvd");
    }
    return null;
}