Example usage for javax.swing JFileChooser JFileChooser

List of usage examples for javax.swing JFileChooser JFileChooser

Introduction

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

Prototype

public JFileChooser(FileSystemView fsv) 

Source Link

Document

Constructs a JFileChooser using the given FileSystemView.

Usage

From source file:cool.pandora.modeller.ui.handlers.base.AddDataHandler.java

/**
 * addData./*from   www .  j  a v  a2  s  .c  om*/
 */
void addData() {
    final File selectFile = new File(File.separator + ".");
    final JFrame frame = new JFrame();
    final JFileChooser fc = new JFileChooser(selectFile);
    fc.setDialogType(JFileChooser.OPEN_DIALOG);
    fc.setMultiSelectionEnabled(true);
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.setDialogTitle("Add File or Directory");
    final int option = fc.showOpenDialog(frame);

    if (option == JFileChooser.APPROVE_OPTION) {
        final File[] files = fc.getSelectedFiles();
        final String message = ApplicationContextUtil.getMessage("bag.message.filesadded");
        if (files != null && files.length > 0) {
            addBagData(files);
            ApplicationContextUtil.addConsoleMessage(message + " " + getFileNames(files));
        } else {
            final File file = fc.getSelectedFile();
            addBagData(file);
            ApplicationContextUtil.addConsoleMessage(message + " " + file.getAbsolutePath());
        }
        bagView.bagPayloadTreePanel.refresh(bagView.bagPayloadTree);
        bagView.updateAddData();
    }
}

From source file:com.wcmc.Software.excel.ExportCMAPoints.java

@Override
public void run() {

    Date now = new Date();

    SimpleDateFormat date = new SimpleDateFormat("yyyy");

    String year = date.format(now);

    JFileChooser saveAs = new JFileChooser(System.getProperty("user.home"));
    saveAs.setDialogTitle("Save Standings For The " + year + " Season");
    saveAs.setFileFilter(new FileNameExtensionFilter("Excel 2003 (*.xls)", "xls"));
    if (saveAs.showSaveDialog(Client.window) == JFileChooser.APPROVE_OPTION) {
        File exportFile = null;/*from  w  ww .  j  a va  2 s .c o m*/
        if (!saveAs.getSelectedFile().toString().endsWith(".xls")) {
            exportFile = new File(saveAs.getSelectedFile().getAbsolutePath() + ".xls");
        } else {
            exportFile = saveAs.getSelectedFile();
        }

        try {
            WritableWorkbook excelFile = Workbook.createWorkbook(exportFile);
            System.out.println("Exporting Standings...");
            int sheetNumber = 0;
            ArrayList<ClassItem> classes = Client.ms.rS.classes.getClasses();

            Client.ms.trS.prgExport.setVisible(true);
            Client.ms.trS.prgExport.setPercent(0);
            Client.ms.trS.prgClass.setVisible(true);
            Client.ms.trS.prgClass.setPercent(0);
            Client.ms.trS.overall.setVisible(true);
            Client.ms.trS.classSpecific.setVisible(true);
            for (int i = 0; i < classes.size(); i++) {
                ClassItem c = classes.get(i);
                Client.ms.trS.classSpecific.setText("Class: " + c.getText());
                WritableSheet classSheet = excelFile.createSheet(c.getText().toString(), sheetNumber);
                classSheet.mergeCells(1, 1, 13, 1);
                classSheet.addCell(new Label(1, 1,
                        c.getText().toString() + " - Niagara Motorcycle Raceway - " + year + " Season",
                        headerGrey));
                classSheet.addCell(new Label(1, 3, "Plate #", headerBold));
                classSheet.addCell(new Label(2, 3, "CMA", headerBold));
                classSheet.addCell(new Label(3, 3, "First Name", headerBold));
                classSheet.addCell(new Label(4, 3, "Last Name", headerBold));
                classSheet.addCell(new Label(5, 3, "Total Points", headerBold));
                Client.sc.send(CONST.GET_RACE_DATES + " " + year + CONST.seperator + c.getID());
                String jsonData = null;
                while ((jsonData = Client.sc.getInfo()) == null) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                if (jsonData != null) {

                    JSONParser parse = new JSONParser();
                    JSONObject jsonDates = (JSONObject) parse.parse(jsonData);
                    if (jsonDates != null) {
                        JSONArray jsonDatesArray = (JSONArray) jsonDates.get("dates");
                        JSONArray riderDataArray = (JSONArray) jsonDates.get("riders");
                        if (riderDataArray.size() == 0) {
                            excelFile.removeSheet(sheetNumber);
                            continue;
                        }
                        for (int d = 0; d < jsonDatesArray.size(); d++) {
                            String dateString = (String) jsonDatesArray.get(d);
                            classSheet.mergeCells(6 + (d * 2), 3, 6 + (d * 2) + 1, 3);

                            DateFormat customDateFormat = new DateFormat("MMMM dd");
                            WritableCellFormat dateFormat = new WritableCellFormat(customDateFormat);
                            dateFormat.setBorder(Border.ALL, BorderLineStyle.THICK);
                            dateFormat.setAlignment(Alignment.CENTRE);
                            dateFormat.setFont(arial10bold);
                            SimpleDateFormat dateParser = new SimpleDateFormat("yyyy-M-d");

                            Date eventDate = dateParser.parse(dateString);

                            jxl.write.DateTime dateFormatCell = new jxl.write.DateTime(6 + (d * 2), 3,
                                    eventDate, dateFormat);

                            classSheet.addCell(dateFormatCell);
                            classSheet.addCell(new Label(6 + (d * 2), 5, "POS", dataCenter));
                            classSheet.addCell(new Label(6 + (d * 2) + 1, 5, "Points", dataCenter));
                            classSheet.setColumnView(6 + (d * 2), 10);
                            classSheet.setColumnView(6 + (d * 2) + 1, 10);

                        }

                        classSheet.addCell(new Label(6 + jsonDatesArray.size() * 2, 3, "City", headerBold));
                        classSheet.addCell(new Label(7 + jsonDatesArray.size() * 2, 3, "Sponsors", headerBold));
                        classSheet.setColumnView(6 + jsonDatesArray.size() * 2, 25);
                        classSheet.setColumnView(7 + jsonDatesArray.size() * 2, 75);

                        for (int r = 0; r < riderDataArray.size(); r++) {
                            JSONObject rider = (JSONObject) riderDataArray.get(r);
                            JSONObject bike = (JSONObject) rider.get("bike");
                            if (bike != null) {
                                classSheet.addCell(new Number(1, 6 + r, (long) bike.get("plate"), pointsBold));
                            }
                            classSheet.addCell(new Label(2, 6 + r, (String) rider.get("license"), pointsBold));
                            classSheet
                                    .addCell(new Label(3, 6 + r, (String) rider.get("first_name"), dataCenter));
                            classSheet
                                    .addCell(new Label(4, 6 + r, (String) rider.get("last_name"), dataCenter));
                            classSheet
                                    .addCell(new Number(5, 6 + r, (long) rider.get("totalPoints"), pointsBold));

                            JSONArray events = (JSONArray) rider.get("events");
                            boolean hasEvent = false;
                            for (int d = 0; d < jsonDatesArray.size(); d++) {
                                hasEvent = false;
                                for (int e = 0; e < events.size(); e++) {
                                    String dateString = (String) jsonDatesArray.get(d);
                                    JSONObject event = (JSONObject) events.get(e);
                                    if (event.get("date").equals(dateString)) {
                                        classSheet.addCell(new Number(6 + (d * 2), 6 + r,
                                                (long) event.get("position"), dataCenter));
                                        classSheet.addCell(new Number(6 + (d * 2) + 1, 6 + r,
                                                (long) event.get("points"), dataCenter));
                                        hasEvent = true;
                                    }
                                }
                                if (!hasEvent) {
                                    classSheet.addCell(new Label(6 + (d * 2), 6 + r, "", dataCenter));
                                    classSheet.addCell(new Label(6 + (d * 2) + 1, 6 + r, "", dataCenter));
                                }
                            }
                            classSheet.addCell(new Label(6 + (jsonDatesArray.size() * 2), 6 + r,
                                    (String) rider.get("city"), dataCenter));
                            classSheet.addCell(new Label(7 + (jsonDatesArray.size() * 2), 6 + r,
                                    (String) rider.get("sponsors"), dataWrapped));
                            Client.ms.trS.prgClass
                                    .setPercent(((double) r / (double) riderDataArray.size()) * 100);
                        }
                    }
                }

                // Set Widths
                classSheet.setRowView(3, 300);

                classSheet.setColumnView(1, 10);
                classSheet.setColumnView(2, 10);
                classSheet.setColumnView(3, 18);
                classSheet.setColumnView(4, 18);
                classSheet.setColumnView(5, 15);
                sheetNumber++;

                Client.ms.trS.prgExport
                        .setPercent(((double) i / (double) Client.ms.rS.classes.getClasses().size()) * 100);
            }
            excelFile.write();
            excelFile.close();

            WorkBook sortedWorkbook = new WorkBook();
            try {
                sortedWorkbook.read(new FileInputStream(exportFile));
                for (int i = 0; i < sheetNumber; i++) {
                    sortedWorkbook.setSheet(i);
                    sortedWorkbook.sort(6, 1, 60, 60, true, -5, 0, 0);
                }
                sortedWorkbook.setSheet(0);
                FileOutputStream out = new FileOutputStream(exportFile);
                sortedWorkbook.write(out);
                out.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
            Client.ms.trS.prgExport.setVisible(false);
            Client.ms.trS.prgClass.setVisible(false);
            Client.ms.trS.overall.setVisible(false);
            Client.ms.trS.classSpecific.setVisible(false);
        } catch (IOException | WriteException | ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (java.text.ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:com.bwc.ora.OraUtils.java

public static File selectFile(boolean openDialog, Component parent, int selectorType, String selectDescription,
        String extensionDescription, String... extentions) {
    File prevLocation = fc.getSelectedFile() != null ? fc.getSelectedFile().getParentFile() : null;

    fc = new JFileChooser(prevLocation);
    fc.setMultiSelectionEnabled(false);// www  . j a  va2 s. c om
    fc.setFileSelectionMode(selectorType);
    if (selectorType == JFileChooser.FILES_ONLY) {
        fc.setFileFilter(new FileNameExtensionFilter(extensionDescription, extentions));
    }
    fc.setAcceptAllFileFilterUsed(false);
    fc.setApproveButtonText("Select");
    fc.setDialogTitle("Select " + selectDescription + "...");
    int returnVal = openDialog ? fc.showOpenDialog(parent) : fc.showSaveDialog(parent);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        if (selectorType == JFileChooser.FILES_ONLY) {
            System.out.println("pwd: " + fc.getCurrentDirectory());
            return openDialog ? loadFile(fc.getSelectedFile()) : fc.getSelectedFile();
        } else if (selectorType == JFileChooser.DIRECTORIES_ONLY) {
            return loadDir(fc.getSelectedFile());
        } else {
            throw new IllegalArgumentException(
                    "Can't handle loading of files or directories at the same time!");
        }
    } else {
        return null;
    }
}

From source file:jmap2gml.ScriptGui.java

/**
 * Formats the window, initializes the JMap2Script object, and sets up all
 * the necessary events.//w w w .  ja  v  a2s.c  o  m
 */
public ScriptGui() {
    setTitle("jmap to gml script converter");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    getContentPane().setLayout(new GridBagLayout());

    this.addWindowListener(new WindowListener() {
        @Override
        public void windowOpened(WindowEvent we) {
        }

        @Override
        public void windowClosing(WindowEvent we) {
            saveConfig();
        }

        @Override
        public void windowClosed(WindowEvent we) {
        }

        @Override
        public void windowIconified(WindowEvent we) {
        }

        @Override
        public void windowDeiconified(WindowEvent we) {
        }

        @Override
        public void windowActivated(WindowEvent we) {
        }

        @Override
        public void windowDeactivated(WindowEvent we) {
        }
    });

    GridBagConstraints c = new GridBagConstraints();

    setResizable(true);
    setIconImage((new ImageIcon("spikeup.png")).getImage());

    jta = new JTextArea(38, 30);

    loadConfig();

    JScrollPane jsp = new JScrollPane(jta);
    jsp.setRowHeaderView(new TextLineNumber(jta));
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jsp.setSize(jsp.getWidth(), 608);

    // menu bar
    JMenuBar menubar = new JMenuBar();

    // file menu
    JMenu file = new JMenu("File");

    // load button
    JMenuItem load = new JMenuItem("Load jmap");
    load.addActionListener(ae -> {
        JFileChooser fileChooser = new JFileChooser(prevDirectory);
        fileChooser.setFileFilter(new FileNameExtensionFilter("jmap file", "jmap", "jmap"));

        int returnValue = fileChooser.showOpenDialog(null);

        if (returnValue == JFileChooser.APPROVE_OPTION) {
            File selectedFile = fileChooser.getSelectedFile();

            prevDirectory = selectedFile.getAbsolutePath();

            jm2s = new ScriptFromJmap(selectedFile.getPath(), false);

            jta.setText("");
            jta.append(jm2s.toString());
            jta.setCaretPosition(0);

            writeFile.setEnabled(true);

            drawPanel.setItems(jta.getText().split("\n"));
        }
    });

    // add load to file menu
    file.add(load);

    // button to save script to file
    writeFile = new JMenuItem("Write file");
    writeFile.addActionListener(ae -> {
        if (jm2s != null) {
            PrintWriter out;
            try {
                File f = new File(
                        jm2s.getFileName().substring(0, jm2s.getFileName().lastIndexOf(".jmap")) + ".gml");
                out = new PrintWriter(f);
                out.append(jm2s.toString());
                out.close();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
    writeFile.setEnabled(false);

    JMenuItem gmx = new JMenuItem("Export as gmx");
    gmx.addActionListener(ae -> {
        String fn = String.format("%s.room.gmx", prevDirectory);

        JFileChooser fc = new JFileChooser(prevDirectory);
        fc.setSelectedFile(new File(fn));
        fc.setFileFilter(new FileNameExtensionFilter("Game Maker XML", "gmx", "gmx"));
        fc.showDialog(null, "Save");
        File f = fc.getSelectedFile();

        if (f != null) {
            try {
                GMX.itemsToGMX(drawPanel.items, new FileOutputStream(f));
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ScriptGui.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });

    // add to file menu
    file.add(writeFile);
    file.add(gmx);

    // add file menu to the menubar
    menubar.add(file);

    // Edit menu

    // display menu
    JMenu display = new JMenu("Display");

    JMenuItem update = new JMenuItem("Update");

    update.addActionListener(ae -> {
        drawPanel.setItems(jta.getText().split("\n"));
    });

    display.add(update);

    JMenuItem gridToggle = new JMenuItem("Toggle Grid");
    gridToggle.addActionListener(ae -> {
        drawPanel.toggleGrid();
    });
    display.add(gridToggle);

    JMenuItem gridOptions = new JMenuItem("Modify Grid");
    gridOptions.addActionListener(ae -> {
        drawPanel.modifyGrid();
    });
    display.add(gridOptions);

    menubar.add(display);

    // sets the menubar
    setJMenuBar(menubar);

    // add the text area to the window
    c.gridx = 0;
    c.gridy = 0;
    add(jsp, c);

    // initialize the preview panel
    drawPanel = new Preview(this);
    JScrollPane scrollPane = new JScrollPane(drawPanel);

    // add preview panel to the window
    c.gridx = 1;
    c.gridwidth = 2;
    add(scrollPane, c);

    pack();
    setMinimumSize(this.getSize());
    setLocationRelativeTo(null);
    setVisible(true);
    drawPanel.setItems(jta.getText().split("\n"));
}

From source file:TextFileHandler.java

public File[] openFiles(String title) {
    File[] result = null;/*from ww w . j ava  2s.co  m*/
    JFileChooser chooser = new JFileChooser(new File("."));
    if (title != null)
        chooser.setDialogTitle(title);
    chooser.setMultiSelectionEnabled(true);
    int retVal = chooser.showOpenDialog(null);
    if (retVal == JFileChooser.APPROVE_OPTION) {
        result = chooser.getSelectedFiles();
    }
    return result;
}

From source file:EnhancedFileTester.java

public EnhancedFileTester() {
    JButton jb = new JButton("Open File Viewer");
    add(jb);//w ww .  j  a  v  a2  s . co  m
    ActionListener listener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser(".");
            FileFilter type1 = new ExtensionFilter("Java source", ".java");
            FileFilter type2 = new ExtensionFilter("Image files",
                    new String[] { ".jpg", ".gif", "jpeg", "xbm" });
            FileFilter type3 = new ExtensionFilter("HTML files", new String[] { ".htm", ".html" });
            chooser.addChoosableFileFilter(type1);
            chooser.addChoosableFileFilter(type2);
            chooser.addChoosableFileFilter(type3);
            chooser.setFileFilter(type2); // Initial filter setting
            FileView view = new IconView();
            chooser.setFileView(view);
            int status = chooser.showOpenDialog(EnhancedFileTester.this);
            if (status == JFileChooser.APPROVE_OPTION) {
                File f = chooser.getSelectedFile();
                System.out.println(f);
            }
        }
    };
    jb.addActionListener(listener);
}

From source file:dotaSoundEditor.Controls.EditorPanel.java

protected File promptUserForNewFile(String wavePath) {
    JFileChooser chooser = new JFileChooser(new File(UserPrefs.getInstance().getWorkingDirectory()));
    FileNameExtensionFilter filter = new FileNameExtensionFilter("MP3s and WAVs", "mp3", "wav");
    chooser.setAcceptAllFileFilterUsed((false));
    chooser.setFileFilter(filter);/*  ww w  .  j a v  a  2 s.c  o m*/
    chooser.setMultiSelectionEnabled(false);

    int chooserRetVal = chooser.showOpenDialog(chooser);
    if (chooserRetVal == JFileChooser.APPROVE_OPTION) {
        DefaultMutableTreeNode selectedFile = (DefaultMutableTreeNode) getTreeNodeFromWavePath(wavePath);
        Path chosenFile = Paths.get(chooser.getSelectedFile().getAbsolutePath());
        //Strip caps and spaces out of filenames. The item sound parser seems to have trouble with them.
        String destFileName = chosenFile.getFileName().toString().toLowerCase().replace(" ", "_");
        Path destPath = Paths.get(installDir, "/dota/sound/" + getCustomSoundPathString() + destFileName);
        UserPrefs.getInstance().setWorkingDirectory(chosenFile.getParent().toString());

        try {
            new File(destPath.toString()).mkdirs();
            Files.copy(chosenFile, destPath, StandardCopyOption.REPLACE_EXISTING);

            String waveString = selectedFile.getUserObject().toString();
            int startIndex = -1;
            int endIndex = -1;
            if (waveString.contains("\"wave\"")) {
                startIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 2);
                endIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 3);
            } else //Some wavestrings don't have the "wave" at the beginning for some reason
            {
                startIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 0);
                endIndex = Utility.nthOccurrence(selectedFile.getUserObject().toString(), '\"', 1);
            }

            String waveStringFilePath = waveString.substring(startIndex, endIndex + 1);
            waveString = waveString.replace(waveStringFilePath,
                    "\"" + getCustomSoundPathString() + destFileName + "\"");
            selectedFile.setUserObject(waveString);

            //Write out modified tree to scriptfile.
            ScriptParser parser = new ScriptParser(this.currentTreeModel);
            String scriptString = getCurrentScriptString();
            Path scriptPath = Paths.get(scriptString);
            parser.writeModelToFile(scriptPath.toString());

            //Update UI
            ((DefaultMutableTreeNode) currentTree.getLastSelectedPathComponent()).setUserObject(waveString);
            ((DefaultTreeModel) currentTree.getModel())
                    .nodeChanged((DefaultMutableTreeNode) currentTree.getLastSelectedPathComponent());
            JOptionPane.showMessageDialog(this, "Sound file successfully replaced.");

        } catch (IOException ex) {
            JOptionPane.showMessageDialog(null, "Unable to replace sound.\nDetails: " + ex.getMessage(),
                    "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
    return null;
}

From source file:task5.deneme.java

private void btn_chooseImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_chooseImageActionPerformed
    //         TODO add your handling code here:
    String userDir = System.getProperty("user.home");

    JFileChooser fileChooser = new JFileChooser(userDir + "/Desktop");

    int result = fileChooser.showOpenDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
        File selectedFile = fileChooser.getSelectedFile();
        try {//from w  ww .  ja v a 2 s  . co m
            img = ImageIO.read(selectedFile);
            getRGBs();

        } catch (IOException ex) {
            Logger.getLogger(deneme.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    r = red.toArray();
    g = green.toArray();
    b = blue.toArray();
    //        
    //        if(red.indexOf(0)==-1 || red.indexOf(255)==-1){
    //            red.sort(null);
    //            System.out.println("Before Streching... Min and Max Value..." );
    //            System.out.println(red.get(0)+"   "+red.get(red.size()-1));
    //            contrastR= red.get(red.size()-1)- red.get(0);
    //            int fmin=red.get(0);
    //            int fmax=red.get(red.size()-1);
    //            for (int i = 0; i < red.size(); i++) {
    //                int temp2=0;
    //                if(((int)r[i])<=fmin)
    //                    temp2=0;
    //                else if(fmin<=((int)r[i]) && ((int)r[i])<= fmax){
    //                    double temp=((((int)r[i])- fmin)/(contrastR));
    //                    temp2=(int) Math.round((temp*255));
    //                }
    //                else if(((int)r[i])>=fmax){
    //                    temp2=255;
    //                }
    //                r[i]=temp2;
    //            }
    //            ArrayList<Integer> tempp = new ArrayList<>();
    //            for (Object r1 : r) {
    //                tempp.add((int) r1);
    //            }
    //            tempp.sort(null);
    //            System.out.println("After Stretching... Min and Max Value...");
    //            System.out.println(tempp.get(0) + "   " + tempp.get(tempp.size() - 1));
    //        }
    //        
    //        
    //        
    //        
    //        
    //        if(green.indexOf(0)==-1 || green.indexOf(255)==-1){
    //            green.sort(null);
    //            contrastG= green.get(green.size()-1)- green.get(0);
    //            int fmin=green.get(0);
    //            int fmax=green.get(green.size()-1);
    //            for (int i = 0; i < green.size(); i++) {
    //                int temp2=0;
    //                if(((int)g[i])<=fmin)
    //                    temp2=0;
    //                else if(fmin<=((int)g[i]) && ((int)g[i])<= fmax){
    //                    double temp=((((int)g[i])- fmin)/(contrastG));
    //                    temp2=(int) Math.round((temp*255));
    //                }
    //                else if(((int)g[i])>=fmax){
    //                    temp2=255;
    //                }
    //                g[i]=temp2;
    //            }
    //        }    
    //        if(blue.indexOf(0)==-1 || blue.indexOf(255)==-1){
    //            blue.sort(null);
    //            contrastB= blue.get(blue.size()-1)- blue.get(0);
    //            int fmin=blue.get(0);
    //            int fmax=blue.get(blue.size()-1);
    //            for (int i = 0; i < blue.size(); i++) {
    //                int temp2=0;
    //                if(((int)b[i])<=fmin)
    //                    temp2=0;
    //                else if(fmin<=((int)b[i]) && ((int)b[i])<= fmax){
    //                    double temp=((((int)b[i])- fmin)/(contrastB));
    //                    temp2=(int) Math.round((temp*255));
    //                }
    //                else if(((int)b[i])>=fmax){
    //                    temp2=255;
    //                }
    //                b[i]=temp2;
    //            }
    //        }

    display();

}

From source file:aurelienribon.gdxsetupui.ui.panels.ConfigUpdatePanel.java

private void browse() {
    String path = Ctx.cfgUpdate.destinationPath;
    JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(this);

    JFileChooser chooser = new JFileChooser(new File(path));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setDialogTitle("Select the core project folder");

    if (chooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
        pathField.setText(chooser.getSelectedFile().getPath());
        updateConfig(chooser.getSelectedFile());
        updatePanel();/*from w  ww .j  av  a2 s .c o m*/
    }
}

From source file:net.aepik.alasca.gui.util.LoadFileFrame.java

/**
 * Perform action on event for this object.
 *//*ww  w  . j ava  2s  .  co  m*/
public void actionPerformed(ActionEvent e) {
    Object o = e.getSource();
    if (o == boutonOpenFile) {
        JFileChooser jfcProgramme = new JFileChooser(".");
        jfcProgramme.setMultiSelectionEnabled(false);
        jfcProgramme.setDialogTitle("Selectionner un fichier");
        jfcProgramme.setApproveButtonText("Selectionner");
        jfcProgramme.setApproveButtonToolTipText("Cliquer apres avoir selectionn un fichier");
        jfcProgramme.setAcceptAllFileFilterUsed(false);
        if (jfcProgramme.showDialog(this, null) == JFileChooser.APPROVE_OPTION) {
            try {
                filename.setText(jfcProgramme.getSelectedFile().getCanonicalPath());
            } catch (IOException ioe) {
                JOptionPane.showMessageDialog(null, "Erreur de nom de fichier.", "Erreur",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    }
    if (o == boutonOk && filename.getText().length() != 0) {
        if (!this.loadFile(filename.getText(), (String) this.syntaxes.getSelectedItem())) {
            JOptionPane.showMessageDialog(this, this.getErrorMessage(), "Erreur", JOptionPane.ERROR_MESSAGE);
        } else {
            windowClosing(null);
        }
    }
    if (o == boutonAnnuler) {
        windowClosing(null);
    }
}