Java Code Examples for javax.swing.JFileChooser.approveSelection()

The following are Jave code examples for showing how to use approveSelection() 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: incubator-netbeans   File: FileChooserBuilderTest.java   Source Code and License Vote up 6 votes
public void testSetSelectionApprover() throws Exception {
    FileChooserBuilder instance = new FileChooserBuilder("i");
    File tmp = getWorkDir();
    assertTrue ("Environment is insane", tmp.exists() && tmp.isDirectory());
    File sel = new File(tmp, "tmp" + System.currentTimeMillis());
    if (!sel.exists()) {
        assertTrue (sel.createNewFile());
    }
    instance.setDefaultWorkingDirectory(tmp);
    SA sa = new SA();
    instance.setSelectionApprover(sa);
    JFileChooser ch = instance.createFileChooser();
    ch.setSelectedFile(sel);
    ch.approveSelection();
    sa.assertApproveInvoked(sel);
}
 
Example 2
Project: marathonv5   File: JFileChooserJavaElement.java   Source Code and License Vote up 5 votes
@Override public boolean marathon_select(String value) {
    JFileChooser fc = (JFileChooser) component;
    if (value.equals("")) {
        fc.cancelSelection();
        return true;
    }
    if (fc.isMultiSelectionEnabled()) {
        fc.setSelectedFiles(ChooserHelper.decode(value));
        fc.approveSelection();
        return true;
    }
    fc.setSelectedFile(ChooserHelper.decodeFile(value));
    fc.approveSelection();
    return true;
}