Example usage for javax.swing.filechooser FileNameExtensionFilter FileNameExtensionFilter

List of usage examples for javax.swing.filechooser FileNameExtensionFilter FileNameExtensionFilter

Introduction

In this page you can find the example usage for javax.swing.filechooser FileNameExtensionFilter FileNameExtensionFilter.

Prototype

public FileNameExtensionFilter(String description, String... extensions) 

Source Link

Document

Creates a FileNameExtensionFilter with the specified description and file name extensions.

Usage

From source file:epsi.i5.frame.JFrame.java

/**
 * Creates new form JFrame// ww w.j  av a  2  s  .  c  om
 */
public JFrame() {
    FileNameExtensionFilter filter = new FileNameExtensionFilter("JSON file", "json");
    initComponents();
    jFileChooser1.setFileFilter(filter);
}

From source file:net.fabricmc.installer.installer.LocalVersionInstaller.java

public static void installServer(File mcDir, IInstallerProgress progress) throws Exception {
    JFileChooser fc = new JFileChooser();
    fc.setDialogTitle(Translator.getString("install.client.selectCustomJar"));
    fc.setFileFilter(new FileNameExtensionFilter("Jar Files", "jar"));
    if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        File inputFile = fc.getSelectedFile();

        JarFile jarFile = new JarFile(inputFile);
        Attributes attributes = jarFile.getManifest().getMainAttributes();
        String fabricVersion = attributes.getValue("FabricVersion");
        jarFile.close();/*w ww .  ja  v  a  2 s  . com*/
        File fabricJar = new File(mcDir, "fabric-" + fabricVersion + ".jar");
        if (fabricJar.exists()) {
            fabricJar.delete();
        }
        FileUtils.copyFile(inputFile, fabricJar);
        ServerInstaller.install(mcDir, fabricVersion, progress, fabricJar);
    } else {
        throw new Exception("Failed to find jar");
    }

}

From source file:com.googlecode.bpmn_simulator.gui.dialogs.ImageExportChooser.java

public ImageExportChooser() {
    super();//from   w ww.  j a va 2  s .  c o m
    setFileSelectionMode(JFileChooser.FILES_ONLY);
    setMultiSelectionEnabled(false);
    setAcceptAllFileFilterUsed(false);
    for (final String suffix : ImageIO.getWriterFileSuffixes()) {
        addChoosableFileFilter(new FileNameExtensionFilter(suffix, suffix));
    }
}

From source file:ihm.mainActivity.java

/**
 * Creates new form testBuild/*from   www.j a v a  2s. c  o  m*/
 */
public mainActivity() {
    dataList = new DataList();
    dataList.addObserver(this);
    chart = ChartFactory.createXYLineChart("Graphique", "x", "Value", createDataset(), PlotOrientation.VERTICAL,
            true, true, false);
    fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV Files", "csv");
    fileChooser.setFileFilter(filter);
    initComponents();
}

From source file:com.itd.dbmrgdao.TestTime4.java

@Ignore
@org.junit.Test/*from  w ww .java  2 s  .co m*/
public void test() throws ParseException {
    String newTab = "\t";
    String[] sysidLine;

    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Text File", "txt");
    chooser.setFileFilter(filter);
    chooser.showOpenDialog(null);
    File f = chooser.getSelectedFile();

    String filename = f.getAbsolutePath();
    try {
        FileReader reader = new FileReader(filename);
        BufferedReader br = new BufferedReader(reader);
        String strLine;

        String sysid = null, scdate = null, p1Start = null, p1End = null, p2Start = null, p2End = null,
                otStart = null, otEnd = null;

        StringBuilder mySql = new StringBuilder(
                "INSERT INTO scandata(sc_sysid,sc_scode,scdate,p1start,p1end,p2start,p2end,otstart,otend) VALUES (?,?,?,?,?,?,?,?,?)");

        while ((strLine = br.readLine()) != null) {
            String[] parts = strLine.split(" ");

            if (sysid != null && !sysid.equals(parts[0])) {
                mySql = mySql.append(", (").append(sysid).append(",\"1985\"").append(",").append(scdate)
                        .append(",").append(p1Start).append(",").append(p1End).append(",").append(p2Start)
                        .append(",").append(p2End).append(",").append(otStart).append(",").append(otEnd)
                        .append(")");

                //                    if (p1Start != null || p2End != null) {
                //                        ScanRule scanRule = scanDao.findScanRuleBySysId(sysid);
                //                        p1Start = scanRule.getP1start();
                //                        p2End = scanRule.getP2end();
                //                    }
                //                    ScanDataTest scanData = new ScanDataTest(sysid, scdate, p1Start, p2End);

                p1Start = null;
                p2End = null;

            }

            sysid = parts[0];
            scdate = parts[1];

            if (parts[6].equals("01")) {
                p1Start = CompareTime(p1Start, parts[5], "01");
            } else {
                p2End = CompareTime(p2End, parts[5], "04");
            }

        }

        //last line
        //            if (p1Start != null || p2End != null) {
        //                ScanRule scanRule = scanDao.findScanRuleBySysId(sysid);
        //                p1Start = scanRule.getP1start();
        //                p2End = scanRule.getP2end();
        //            }
        //            ScanDataTest scanData = new ScanDataTest(sysid, scdate, p1Start, p2End);
        //            System.out.println(scanData);
        br.close();

    } catch (Exception e) {

        JOptionPane.showMessageDialog(null, e);

    }

}

From source file:rework.MainFrame.java

/**
 * Creates new form MainFrame/* w  w w.j a v a  2 s .  c  om*/
 */
public MainFrame() {
    chart = ChartFactory.createXYLineChart("Graphique", "x", "Value", createDataset(), PlotOrientation.VERTICAL,
            true, true, false);

    initComponents();

    fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV Files", "csv");
    fileChooser.setFileFilter(filter);

    layerStack1.initComponents(transfList);
    layerStack1.updateLayerStack();

    datalist.addObserver(this);
    transfList.addObserver(layerStack1);

    datalist.add(new Point(new Date(), 1, 5.0));
    datalist.add(new Point(new Date(), 2, 15.0));
    datalist.add(new Point(new Date(), 3, 25.0));
    datalist.add(new Point(new Date(), 4, 20.0));
    datalist.add(new Point(new Date(), 5, 25.0));
    datalist.add(new Point(new Date(), 6, 35.0));
    datalist.add(new Point(new Date(), 7, 5.0));
    datalist.add(new Point(new Date(), 8, 15.0));
    datalist.add(new Point(new Date(), 9, 25.0));
    datalist.add(new Point(new Date(), 10, 20.0));
    datalist.add(new Point(new Date(), 11, 25.0));
    datalist.add(new Point(new Date(), 12, 35.0));
    datalist.add(new Point(new Date(), 13, 5.0));
    datalist.add(new Point(new Date(), 14, 15.0));
    datalist.add(new Point(new Date(), 15, 25.0));
    datalist.add(new Point(new Date(), 16, 20.0));
    datalist.add(new Point(new Date(), 17, 25.0));
    datalist.add(new Point(new Date(), 18, 35.0));

    tabStack.revalidate();

}

From source file:com.dieterholvoet.scoutsapp.util.CSVParser.java

public CSVParser(WerkstukGUI WerkstukGUI) {
    this.parent = WerkstukGUI;
    this.c = new ColumnHolder();

    this.filter = new FileNameExtensionFilter("CSV Files", "csv");
    this.chooser = new JFileChooser();
    this.chooser.setFileFilter(this.filter);
}

From source file:com.itd.dbmrgdao.TestTime3_backup.java

@Ignore
@org.junit.Test//from  w ww .java2  s  .  co m
public void test() throws ParseException {
    String newTab = "\t";
    String[] sysidLine;

    JFileChooser chooser = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Text File", "txt");
    chooser.setFileFilter(filter);
    chooser.showOpenDialog(null);
    File f = chooser.getSelectedFile();

    String filename = f.getAbsolutePath();
    try {
        FileReader reader = new FileReader(filename);
        BufferedReader br = new BufferedReader(reader);
        String strLine;

        String sysid = null, p1Start = null, p1End = null, p2Start = null, p2End = null, otStart = null,
                otEnd = null;
        Date scdate = null;

        // read from select file
        while ((strLine = br.readLine()) != null) {
            String[] parts = strLine.split(" ");

            // check if not first record or sysid change will save in table scandata 
            if (sysid != null && !sysid.equals(parts[0])) {
                // rule if whatever employee register will get standard hour 8 hrs
                if (p1Start != null || p2End != null) {
                    ScanRule scanRule = scanDao.findScanRuleBySysId(sysid);
                    p1Start = scanRule.getP1start();
                    p2End = scanRule.getP2end();
                }

                // set up data in entity
                ScanDataKey scanDataKey = new ScanDataKey(sysid, scdate);
                ScanData scanData = new ScanData(scanDataKey, "1985", p1Start, p1End, p2Start, p2End, otStart,
                        otEnd);
                // remove old record (key is sysid and scdate)
                gennericDao.remove(scanData);
                gennericDao.create(scanData);

                //clear 
                p1Start = null;
                p1End = null;
                p2Start = null;
                p2End = null;
                otStart = null;
                otEnd = null;

            }

            sysid = parts[0];
            scdate = new SimpleDateFormat("yyyyMMdd", Locale.US).parse(parts[1]);

            if (parts[6].equals("01")) {
                p1Start = CompareTime(p1Start, parts[5], "01");
            } else {
                p2End = CompareTime(p2End, parts[5], "04");
            }

        }
        //last line

        if (p1Start != null || p2End != null) {
            ScanRule scanRule = scanDao.findScanRuleBySysId(sysid);
            p1Start = scanRule.getP1start();
            p2End = scanRule.getP2end();
        }

        ScanDataKey scanDataKey = new ScanDataKey(sysid, scdate);
        ScanData scanData = new ScanData(scanDataKey, "1985", p1Start, p1End, p2Start, p2End, otStart, otEnd);
        gennericDao.remove(scanData);
        gennericDao.create(scanData);

        br.close();

    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }

}

From source file:edu.clemson.lph.civet.addons.VspsCviFile.java

public void importVspsFile(Window parent) {
    String sVspsDir = CivetConfig.getVspsDirPath();
    File fDir = new File(sVspsDir);
    JFileChooser open = new JFileChooser(fDir);
    Action details = open.getActionMap().get("viewTypeDetails");
    details.actionPerformed(null);/*w w w.j av a2  s . com*/
    open.setDialogTitle("Civet: Open PDF File");
    open.setFileSelectionMode(JFileChooser.FILES_ONLY);
    open.setFileFilter(new FileNameExtensionFilter("CSV Files", "csv"));
    open.setMultiSelectionEnabled(false);
    int resultOfFileSelect = open.showOpenDialog(parent);
    if (resultOfFileSelect == JFileChooser.APPROVE_OPTION) {
        File fIn = open.getSelectedFile();
        saveme(parent, fIn);
        //          vsps.printme();
    }

}

From source file:com.opendoorlogistics.utils.image.ExportImagePanel.java

public ExportImagePanel(ExportImageConfig inputConfig) {
    super(inputConfig);
    this.config = inputConfig;

    addCheckBox("Save to clipboard", config.isToClipboard(), new CheckChangedListener() {
        @Override/*w ww  . j  a  v  a2  s.  c  om*/
        public void checkChanged(boolean isChecked) {
            ExportImagePanel.this.config.setToClipboard(isChecked);
        }
    });

    addCheckBox("Save to file", config.isToFile(), new CheckChangedListener() {
        @Override
        public void checkChanged(boolean isChecked) {
            ExportImagePanel.this.config.setToFile(isChecked);
            //   updateAppearance();
        }
    });

    FileNameExtensionFilter[] filters = new FileNameExtensionFilter[ImageType.values().length];
    for (int i = 0; i < filters.length; i++) {
        ImageType type = ImageType.values()[i];
        filters[i] = new FileNameExtensionFilter("Image file (" + type.name().toLowerCase() + ")",
                type.name().toLowerCase());
    }
    fileBrowser = new FileBrowserPanel(this.config.getFilename(), new FilenameChangeListener() {

        @Override
        public void filenameChanged(String newFilename) {
            ExportImagePanel.this.config.setFilename(newFilename);
            String ext = FilenameUtils.getExtension(newFilename);
            for (ImageType type : ImageType.values()) {
                if (Strings.equalsStd(ext, type.name())) {
                    imageTypeCombo.getComboBox().setSelectedItem(type);
                    config.setImageType(type);
                    break;
                }
            }
        }
    }, false, "Select file", filters);
    add(fileBrowser);

    validateFilename();
}