Example usage for javax.swing JFileChooser getSelectedFile

List of usage examples for javax.swing JFileChooser getSelectedFile

Introduction

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

Prototype

public File getSelectedFile() 

Source Link

Document

Returns the selected file.

Usage

From source file:org.streamspinner.harmonica.application.CQGraphTerminal.java

private void show_open_hamql_dialog() {
    FileFilter filter = createFilter();

    JFileChooser jf = new JFileChooser("conf/query/");
    jf.setFileFilter(filter);// w  w w  .  j  a  va2 s  . com

    jf.setDialogTitle("HamQL (SpinQL) ?J");

    int returnVal = jf.showOpenDialog(this);
    if (returnVal != JFileChooser.APPROVE_OPTION)
        return;

    File f = jf.getSelectedFile();

    try {
        FileReader reader = new FileReader(f);
        BufferedReader br = new BufferedReader(reader);

        StringBuilder buf = new StringBuilder();
        String tmp = null;
        while ((tmp = br.readLine()) != null) {
            buf.append(tmp + "\n");
        }
        br.close();
        reader.close();

        getJTextArea().setText(buf.toString());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.ficeto.esp.EspExceptionDecoder.java

private void createAndUpload() {
    if (!PreferencesData.get("target_platform").contentEquals("esp8266")
            && !PreferencesData.get("target_platform").contentEquals("esp32")
            && !PreferencesData.get("target_platform").contentEquals("ESP31B")) {
        System.err.println();// www  .  jav a  2  s.  c  om
        editor.statusError("Not Supported on " + PreferencesData.get("target_platform"));
        return;
    }

    String tc = "esp32";
    if (PreferencesData.get("target_platform").contentEquals("esp8266")) {
        tc = "lx106";
    }

    TargetPlatform platform = BaseNoGui.getTargetPlatform();

    String gccPath = PreferencesData.get("runtime.tools.xtensa-" + tc + "-elf-gcc.path");
    if (gccPath == null) {
        gccPath = platform.getFolder() + "/tools/xtensa-" + tc + "-elf";
    }

    String addr2line;
    if (PreferencesData.get("runtime.os").contentEquals("windows"))
        addr2line = "xtensa-" + tc + "-elf-addr2line.exe";
    else
        addr2line = "xtensa-" + tc + "-elf-addr2line";

    tool = new File(gccPath + "/bin", addr2line);
    if (!tool.exists() || !tool.isFile()) {
        System.err.println();
        editor.statusError("ERROR: " + addr2line + " not found!");
        return;
    }

    elf = new File(getBuildFolderPath(editor.getSketch()), editor.getSketch().getName() + ".ino.elf");
    if (!elf.exists() || !elf.isFile()) {
        elf = new File(getBuildFolderPath(editor.getSketch()), editor.getSketch().getName() + ".cpp.elf");
        if (!elf.exists() || !elf.isFile()) {
            //lets give the user a chance to select the elf
            final JFileChooser fc = new JFileChooser();
            fc.addChoosableFileFilter(new ElfFilter());
            fc.setAcceptAllFileFilterUsed(false);
            int returnVal = fc.showDialog(editor, "Select ELF");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                elf = fc.getSelectedFile();
            } else {
                editor.statusError("ERROR: elf was not found!");
                System.err.println("Open command cancelled by user.");
                return;
            }
        }
    }

    JFrame.setDefaultLookAndFeelDecorated(true);
    frame = new JFrame("Exception Decoder");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    inputArea = new JTextArea("Paste your stack trace here", 16, 60);
    inputArea.setLineWrap(true);
    inputArea.setWrapStyleWord(true);
    inputArea.getInputMap().put(KeyStroke.getKeyStroke("ENTER"), "commit");
    inputArea.getActionMap().put("commit", new CommitAction());
    inputArea.getDocument().addDocumentListener(this);
    frame.getContentPane().add(new JScrollPane(inputArea), BorderLayout.PAGE_START);

    outputText = "";
    outputArea = new JTextPane();
    outputArea.setContentType("text/html");
    outputArea.setEditable(false);
    outputArea.setBackground(null);
    outputArea.setBorder(null);
    outputArea.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    outputArea.setText(outputText);

    JScrollPane outputScrollPane = new JScrollPane(outputArea);
    outputScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    outputScrollPane.setPreferredSize(new Dimension(640, 200));
    outputScrollPane.setMinimumSize(new Dimension(10, 10));
    frame.getContentPane().add(outputScrollPane, BorderLayout.CENTER);

    frame.pack();
    frame.setVisible(true);
}

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;/* www.  j  a v a  2 s  . com*/
        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:edu.uchc.octane.OctanePlugin.java

@Override
public void run(String cmd) {

    if (!IJ.isJava16()) {

        IJ.error("Octane requires Java version 1.6 or higher. Please upgrade the JVM.");
        return;//from w ww  . ja  v a2s  . co  m

    }

    try {

        Class.forName("org.apache.commons.math3.util.FastMath");

    } catch (ClassNotFoundException e) {

        IJ.error("This version of Octane requires Apache Commons Math v3.0 or later. Please install.");
        return;
    }

    imp_ = WindowManager.getCurrentImage();

    if (imp_ == null || imp_.getStack().getSize() < 2) {

        IJ.error("This only works on an opened image stack.");
        return;

    }

    FileInfo fi = imp_.getOriginalFileInfo();
    String path;

    if (fi != null) {

        path = fi.directory;

    } else {

        IJ.error("Can't find image's disk location. You must save the data on disk first.");
        return;

    }

    if (dict_.containsKey(imp_)) { // window already open

        OctanePlugin plugin = dict_.get(imp_);

        if (plugin != null && cmd.equals("load")) {

            plugin.ctl_.getWindow().setVisible(true);
            return;

        } else {

            // do nothing

        }
    }

    if (cmd.startsWith("analyze")) {

        if (startImageAnalysis(cmd)) { // wasOked?

            SmNode[][] nodes = dlg_.processAllFrames();

            if (TrackingParameters.openDialog(dlg_.pixelSize_)) { //wasOKed ?

                TrajDataset data = TrajDataset.createDatasetFromNodes(nodes);
                data.setPixelSize(dlg_.pixelSize_);

                ctl_ = new OctaneWindowControl(imp_);

                String filename = ctl_.defaultSaveFilename();
                File file = new File(filename);

                if (file.exists()) {

                    int idx = 1;
                    File newFile;

                    do {

                        String backupName = filename + ".b" + idx;
                        newFile = new File(backupName);

                        idx++;

                    } while (newFile.exists());

                    if (!file.renameTo(newFile)) {

                        IJ.error("Problem renaming old dataset file");
                        return;

                    }

                }

                openWindow(data);

                ctl_.saveDataset();

                return;
            }
        }

        dict_.remove(imp_);
    }

    if (cmd.startsWith("calibration")) {

        startImageAnalysis(cmd);
        dict_.remove(imp_);

    }

    if (cmd.equals("load")) {

        assert (path != null);

        File file = new File(path + File.separator + imp_.getTitle() + ".dataset");

        if (file.exists()) {

            try {

                ctl_ = new OctaneWindowControl(imp_);

                openWindow(readDataset(file));

            } catch (IOException e) {

                IJ.error("An IO error occured reading file: " + file.getName() + "\n "
                        + e.getLocalizedMessage());

            } catch (ClassNotFoundException e) {

                IJ.error("Can't recognize the file format: " + file.getName() + "\n" + e.getLocalizedMessage());

            }
        } else {

            IJ.error("Can't find previous analysis results."
                    + " It needs to be saved in the same folder as your image data.");

        }

        return;

    }

    if (cmd.equals("import")) {

        JFileChooser fc = new JFileChooser();

        if (fc.showOpenDialog(IJ.getApplet()) == JFileChooser.APPROVE_OPTION) {
            try {

                ctl_ = new OctaneWindowControl(imp_);

                openWindow(TrajDataset.importDatasetFromText(fc.getSelectedFile()));

                ctl_.saveDataset();

            } catch (IOException e) {

                IJ.error("An IO error occured reading file: " + fc.getSelectedFile().getName());
                return;
            }
        }

        return;
    }
}

From source file:ch.bfh.lca._15h.server.gui.MainWindowServer.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

    // JFileChooser-Objekt erstellen
    JFileChooser chooser = new JFileChooser();
    // Dialog zum Speichern von Dateien anzeigen
    int resultValue = chooser.showDialog(null, "Bitte whle die json Datei aus, die Sie importieren mchten");

    if (resultValue == JFileChooser.APPROVE_OPTION) {
        this.txtJsonPath.setText(chooser.getSelectedFile().getAbsolutePath());
        ImportHandler ih = new ImportHandler(this.txtJsonPath.getText(), this.txtDatabasePath.getText());
        ih.importData();/*from  w w w  .  j  a  v a2 s . c o  m*/
        JOptionPane.showMessageDialog(new JFrame(), "Import finished", "Information",
                JOptionPane.INFORMATION_MESSAGE);
    }

}

From source file:VentanaPrincipal.java

private void subirFichero() throws IOException {
    String directorio = lblRuta.getText();
    cliente.changeWorkingDirectory(directorio);
    cliente.setFileType(FTP.BINARY_FILE_TYPE);

    JFileChooser chooser = new JFileChooser();
    int returnVal = chooser.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        BufferedInputStream in = new BufferedInputStream(
                new FileInputStream(chooser.getSelectedFile().getAbsolutePath()));
        cliente.storeFile(chooser.getSelectedFile().getName(), in);
        listFicheros.add(chooser.getSelectedFile().getName() + "- Fichero");
        in.close();/*ww  w  . j  a  va2  s.c  o  m*/
        lblMens.setText("Documento subido con xito");
    }
}

From source file:baocaoxla.compare.java

private void btInputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInputActionPerformed
    JFileChooser fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.showOpenDialog(this);
    File dir = fc.getSelectedFile();
    txtInput.setText(dir.toString());/*from   w w w .ja  va  2s. c  o m*/
    /* File[] file=dir.listFiles(new FilenameFilter() {
            
     @Override
     public boolean accept(File dir, String name) {
     return name.toLowerCase().endsWith(".jpg"); //To change body of generated methods, choose Tools | Templates.
     }
     });*/
    //File[] file = dir.listFiles();
    //for (int i = 0; i < file.length; i++) {
    //  System.out.println(file[i].getName());
    //}

}

From source file:edu.harvard.i2b2.adminTool.dataModel.PatientIDConversionFactory.java

private String getKey() {
    String path = null;/*from  ww w  .  ja  va 2 s .  c o m*/
    String key = UserInfoBean.getInstance().getKey();
    if (key == null) {
        if ((path = getNoteKeyDrive()) == null) {
            Object[] possibleValues = { "Type in the key", "Browse to find the file containing the key" };
            String selectedValue = (String) JOptionPane.showInputDialog(null,
                    "You have selected an item associated with a report\n"
                            + "which contains protected health information.\n"
                            + "You need a decryption key to perform this operation.\n"
                            + "How would you like to enter the key?\n"
                            + "(If the key is on a floppy disk, insert the disk then\n select "
                            + "\"Browse to find the file containing the key\")",
                    "Notes Viewer", JOptionPane.QUESTION_MESSAGE, null, possibleValues, possibleValues[0]);
            if (selectedValue == null) {
                return "Not a valid key";
            }
            if (selectedValue.equalsIgnoreCase("Type in the key")) {
                key = JOptionPane.showInputDialog(this, "Please input the decryption key");
                if (key == null) {
                    return "Not a valid key";
                }
            } else {
                JFileChooser chooser = new JFileChooser();
                int returnVal = chooser.showOpenDialog(null);
                if (returnVal == JFileChooser.CANCEL_OPTION) {
                    return "Not a valid key";
                }

                File f = null;
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    f = chooser.getSelectedFile();
                    System.out.println("Open this file: " + f.getAbsolutePath());

                    BufferedReader in = null;
                    try {
                        in = new BufferedReader(new FileReader(f.getAbsolutePath()));
                        String line = null;
                        while ((line = in.readLine()) != null) {
                            if (line.length() > 0) {
                                key = line.substring(line.indexOf("\"") + 1, line.lastIndexOf("\""));
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        if (in != null) {
                            try {
                                in.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }
        } else {
            System.out.println("Found key file: " + path);
            BufferedReader in = null;
            try {
                in = new BufferedReader(new FileReader(path));
                String line = null;
                while ((line = in.readLine()) != null) {
                    if (line.length() > 0) {
                        key = line.substring(line.indexOf("\"") + 1, line.lastIndexOf("\""));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    if (key == null) {
        return null;
    } else {
        UserInfoBean.getInstance().setKey(key);
    }
    return key;
}

From source file:org.nekorp.workflow.desktop.view.FormatoProgramacionView.java

private void importarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importarActionPerformed
    try {//from   ww  w .j  a  v a2s . co m
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("Hojas de clculo", "xlsx");
        chooser.setFileFilter(filter);
        String homePath = System.getProperty("user.home");
        File f = new File(new File(homePath).getCanonicalPath());
        chooser.setSelectedFile(f);
        int returnVal = chooser.showOpenDialog(this.mainFrame);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
            this.application.importarArchivo(chooser.getSelectedFile());
            this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
        }
    } catch (IOException ex) {
        FormatoProgramacionView.LOGGER.error(ex);
    }
}

From source file:baocaoxla.compare.java

private void jMenuOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuOpenActionPerformed
    JFileChooser fc = new JFileChooser();
    int f = fc.showOpenDialog(this);
    if (f == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();
        try {// www  .  ja va2  s .  c  om
            img = ImageIO.read(new File(file.getPath()));
            ImageIcon icon = new ImageIcon(
                    img.getScaledInstance(lbimage.getWidth(), lbimage.getHeight(), Image.SCALE_SMOOTH));
            lbimage.setIcon(icon);
            pnimagehistogram.removeAll();
            pnimagehistogram.add(xuly.displayhistogram(img));
            pnimagehistogram.validate();
        } catch (IOException ex) {
            Logger.getLogger(compare.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (jcbtwo.isSelected()) {
            fc.showOpenDialog(this);
            file = fc.getSelectedFile();
            try {
                imgcompare = ImageIO.read(new File(file.getPath()));
                ImageIcon icon1 = new ImageIcon(imgcompare.getScaledInstance(lbimagecompare.getWidth(),
                        lbimagecompare.getHeight(), Image.SCALE_SMOOTH));
                lbimagecompare.setIcon(icon1);
                pnimagehistogram1.removeAll();
                pnimagehistogram1.add(xuly.displayhistogram(imgcompare));
                pnimagehistogram1.validate();
            } catch (IOException ex) {
                Logger.getLogger(compare.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

}