Example usage for javax.swing JFileChooser setSelectedFile

List of usage examples for javax.swing JFileChooser setSelectedFile

Introduction

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

Prototype

@BeanProperty(preferred = true)
public void setSelectedFile(File file) 

Source Link

Document

Sets the selected file.

Usage

From source file:pcgen.gui2.converter.panel.WriteDirectoryPanel.java

@Override
public void setupDisplay(JPanel panel, final CDOMObject pc) {
    panel.setLayout(layout);//from  w  ww. jav a2  s . com
    Component label = new JLabel("Please select the Directory where Converted files should be written: ");
    AbstractButton button = new JButton("Browse...");
    button.setMnemonic('r');
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setDialogType(JFileChooser.OPEN_DIALOG);
            chooser.setCurrentDirectory(path.getParentFile());
            chooser.setSelectedFile(path);
            while (true) {
                int open = chooser.showOpenDialog(null);
                if (open == JFileChooser.APPROVE_OPTION) {
                    File fileToOpen = chooser.getSelectedFile();
                    if (fileToOpen.isDirectory() && fileToOpen.canRead() && fileToOpen.canWrite()) {
                        path = fileToOpen;
                        pc.put(ObjectKey.WRITE_DIRECTORY, path);
                        fileLabel.setText(path.getAbsolutePath());
                        PCGenSettings context = PCGenSettings.getInstance();
                        context.setProperty(PCGenSettings.CONVERT_OUTPUT_SAVE_PATH, path.getAbsolutePath());
                        showWarning();
                        break;
                    }
                    JOptionPane.showMessageDialog(null,
                            "Selection must be a valid " + "(readable & writeable) Directory");
                    chooser.setCurrentDirectory(path.getParentFile());
                } else if (open == JFileChooser.CANCEL_OPTION) {
                    break;
                }
            }
        }
    });
    panel.add(label);
    panel.add(fileLabel);
    panel.add(button);
    panel.add(warningLabel);
    showWarning();
    layout.putConstraint(SpringLayout.NORTH, label, 50, SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.NORTH, fileLabel, 75 + label.getPreferredSize().height,
            SpringLayout.NORTH, panel);
    layout.putConstraint(SpringLayout.NORTH, button, 75 + label.getPreferredSize().height, SpringLayout.NORTH,
            panel);
    layout.putConstraint(SpringLayout.WEST, label, 25, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.WEST, fileLabel, 25, SpringLayout.WEST, panel);
    layout.putConstraint(SpringLayout.EAST, button, -50, SpringLayout.EAST, panel);
    layout.putConstraint(SpringLayout.NORTH, warningLabel, 20, SpringLayout.SOUTH, fileLabel);
    layout.putConstraint(SpringLayout.WEST, warningLabel, 25, SpringLayout.WEST, panel);

    fileLabel.setText(path.getAbsolutePath());
}

From source file:pcgen.gui2.dialog.ExportDialog.java

private void export(boolean pdf) {
    UIPropertyContext context = UIPropertyContext.createContext("ExportDialog");
    final JFileChooser fcExport = new JFileChooser();
    fcExport.setFileSelectionMode(JFileChooser.FILES_ONLY);
    File baseDir = null;/*from   w ww  .  ja v a2 s .co  m*/
    {
        String path;
        if (pdf) {
            path = context.getProperty(PDF_EXPORT_DIR_PROP);
        } else {
            path = context.getProperty(HTML_EXPORT_DIR_PROP);
        }
        if (path != null) {
            baseDir = new File(path);
        }
    }
    if (baseDir == null || !baseDir.isDirectory()) {
        baseDir = SystemUtils.getUserHome();
    }
    fcExport.setCurrentDirectory(baseDir);

    URI uri = fileList.getSelectedValue();
    String extension = ExportUtilities.getOutputExtension(uri.toString(), pdf);
    if (pdf) {
        FileFilter fileFilter = new FileNameExtensionFilter("PDF Documents (*.pdf)", "pdf");
        fcExport.addChoosableFileFilter(fileFilter);
        fcExport.setFileFilter(fileFilter);
    } else if ("htm".equalsIgnoreCase(extension) || "html".equalsIgnoreCase(extension)) {
        FileFilter fileFilter = new FileNameExtensionFilter("HTML Documents (*.htm, *.html)", "htm", "html");
        fcExport.addChoosableFileFilter(fileFilter);
        fcExport.setFileFilter(fileFilter);
    } else if ("xml".equalsIgnoreCase(extension)) {
        FileFilter fileFilter = new FileNameExtensionFilter("XML Documents (*.xml)", "xml");
        fcExport.addChoosableFileFilter(fileFilter);
        fcExport.setFileFilter(fileFilter);
    } else {
        String desc = extension + " Files (*." + extension + ")";
        fcExport.addChoosableFileFilter(new FileNameExtensionFilter(desc, extension));
    }
    String name;
    File path;
    if (!partyBox.isSelected()) {
        CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem();
        path = character.getFileRef().get();
        if (path != null) {
            path = path.getParentFile();
        } else {
            path = new File(PCGenSettings.getPcgDir());
        }
        name = character.getTabNameRef().get();
        if (StringUtils.isEmpty(name)) {
            name = character.getNameRef().get();
        }
    } else {
        path = new File(PCGenSettings.getPcgDir());
        name = "Entire Party";
    }
    if (pdf) {
        fcExport.setSelectedFile(new File(path, name + ".pdf"));
    } else {
        fcExport.setSelectedFile(new File(path, name + "." + extension));
    }
    fcExport.setDialogTitle("Export " + name);
    if (fcExport.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) {
        return;
    }

    final File outFile = fcExport.getSelectedFile();
    if (pdf) {
        context.setProperty(PDF_EXPORT_DIR_PROP, outFile.getParent());
    } else {
        context.setProperty(HTML_EXPORT_DIR_PROP, outFile.getParent());
    }

    if (StringUtils.isEmpty(outFile.getName())) {
        pcgenFrame.showErrorMessage("PCGen", "You must set a filename.");
        return;
    }

    if (outFile.isDirectory()) {
        pcgenFrame.showErrorMessage("PCGen", "You cannot overwrite a directory with a file.");
        return;
    }

    if (outFile.exists() && !SettingsHandler.getAlwaysOverwrite()) {
        int reallyClose = JOptionPane.showConfirmDialog(this,
                "The file " + outFile.getName() + " already exists, are you sure you want to overwrite it?",
                "Confirm overwriting " + outFile.getName(), JOptionPane.YES_NO_OPTION);

        if (reallyClose != JOptionPane.YES_OPTION) {
            return;
        }
    }
    if (pdf) {
        new PDFExporter(outFile, extension, name).execute();
    } else {
        if (!printToFile(outFile)) {
            String message = "The character export failed. Please see the log for details.";
            pcgenFrame.showErrorMessage(Constants.APPLICATION_NAME, message);
            return;
        }
        maybeOpenFile(outFile);
        Globals.executePostExportCommandStandard(outFile.getAbsolutePath());
    }
}

From source file:pcgen.gui2.prefs.LookAndFeelPanel.java

private void selectThemePack() {
    JFileChooser fc = new JFileChooser(ConfigurationSettings.getThemePackDir());
    fc.setDialogTitle(LanguageBundle.getString("in_Prefs_chooseSkinDialogTitle"));

    String theme = LookAndFeelManager.getCurrentThemePack();

    if (StringUtils.isNotEmpty(theme)) {
        fc.setCurrentDirectory(new File(LookAndFeelManager.getCurrentThemePack()));
        fc.setSelectedFile(new File(LookAndFeelManager.getCurrentThemePack()));
    }//from   w w w .j  a  va  2  s . c  o  m

    fc.addChoosableFileFilter(new ThemePackFilter());

    if (fc.showOpenDialog(getParent().getParent()) == JFileChooser.APPROVE_OPTION) //ugly, but it works
    {
        File newTheme = fc.getSelectedFile();

        if (newTheme.isDirectory() || (!newTheme.getName().endsWith("themepack.zip"))) {
            ShowMessageDelegate.showMessageDialog(LanguageBundle.getString("in_Prefs_notAThemeErrorItem"),
                    Constants.APPLICATION_NAME, MessageType.ERROR);
        } else {
            LookAndFeelManager.setSelectedThemePack(newTheme.getAbsolutePath());
        }
    }
}

From source file:pdfreader.PDFReader.java

public void convertToStandardHtml() {
    JFileChooser jfc = new JFileChooser("F:\\rajmeen\\All files together\\PDF to HTML");
    jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    jfc.setSelectedFile(newFile(nameOfFile.substring(0, nameOfFile.length() - 4) + ".html"));
    jfc.showSaveDialog(PDFReader.this);
    File saveFile = jfc.getSelectedFile();
    String outputFileName = saveFile.toString();

    //        String typee = JOptionPane.showInputDialog("Type","3");
    //        int type =  Integer.parseInt(typee);   
    //        String zooom = JOptionPane.showInputDialog("Zoom","2");
    //        int zoom = new Float(zooom);
    //        System.out.println(type+"<---type and zoom--->"+zoom);

    try {//from   w w w  .  ja v a  2 s .c o m
        //                    HtmFile htmlFile = new HtmFile(outputFileName, type, zoom);
        //            StandardHtml shtml = new StandardHtml(outputFileName, 3, 2);
        //            shtml.convertPdfToHtml(name);
        //            shtml.closeFile();

        HtmlFile htmlFile;
        htmlFile = new HtmlFile(outputFileName, 3, 2);
        htmlFile.convertPdfToHtml(name);
        htmlFile.endTable();//used for spanning
        htmlFile.getAllCell();//used for spanning
        htmlFile.closeFile();
    } catch (Exception e) {
        System.err.println("Filed to convert Pdf to Html.");
        e.printStackTrace();
    }
}

From source file:pdfreader.PDFReader.java

public void regionTextAllOnce(java.awt.event.ActionEvent evt) throws IOException, CryptographyException {

    JFileChooser jfc = new JFileChooser("F:\\rajmeen\\All files together\\PDF to HTML");
    jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    jfc.setSelectedFile(newFile(nameOfFile.substring(0, nameOfFile.length() - 4) + ".html"));
    jfc.showSaveDialog(PDFReader.this);
    File saveFile = jfc.getSelectedFile();
    File saveFile1 = jfc.getSelectedFile();
    String outputFileName = saveFile.toString();
    String outputFileName1;/*  w ww  .j  a v a  2  s  .  c om*/
    outputFileName1 = saveFile1.toString().substring(0, (saveFile1.toString().length() - 5)) + ".xml";
    HtmlFileGen htmlFileGen = new HtmlFileGen(name, "C:\\blazeds\\tomcat\\webapps\\pictures\\",
            "localhost:8080/pictures/", getTheFileName(name), "");
    TaggedRegion tr;
    BufferedWriter xmlFile = new BufferedWriter(
            new OutputStreamWriter(new FileOutputStream(outputFileName1), "UTF8"));
    xmlFile.write("<?xml version=\"1.0\"?><Pages>");
    int tempPageNumber = -1;
    try (BufferedWriter htmlFile = new BufferedWriter(
            new OutputStreamWriter(new FileOutputStream(outputFileName), "UTF8"))) {
        for (int i = 0; i < listOfSelectedRegionInRectangle.size(); i++) {
            tr = listOfSelectedRegionInRectangle.get(i);
            if (tempPageNumber == -1)
                xmlFile.write("<Page No = \"" + tr.pageNumber + "\">");
            else if (tempPageNumber != tr.pageNumber)
                xmlFile.write("</Page><Page No = \"" + tr.pageNumber + "\">");
            //                else
            //                    xmlFile.write("<Page No = \""+tr.pageNumber+"\">");
            tempPageNumber = tr.pageNumber;
            String s = htmlFileGen.getHtmlContent(tr.pageNumber, tr.rectangle, tr.tag);
            if ("table".equals(tr.tag) || "list".equals(tr.tag)) {
                twoDRect = htmlFileGen.twoDRect;
            }
            htmlFile.write(s);
            xmlFile.write("<Region x = \"" + tr.rectangle.x + "\" y = \"" + tr.rectangle.y + "\" height = \""
                    + tr.rectangle.height + "\" width = \"" + tr.rectangle.width + "\" type = \"" + tr.tag
                    + "\">");
            xmlFile.write("<HtmlContent>" + StringEscapeUtils.escapeXml(s) + "</HtmlContent></Region>");
            //            System.out.println(s);
        }
    }
    xmlFile.write("</Page></Pages>");
    xmlFile.close();
    listOfSelectedRegionInRectangle = new ArrayList<>();
}

From source file:pdfreader.PDFReader.java

private void listExtract(java.awt.event.ActionEvent evt) {
    JFileChooser jfc = new JFileChooser("F:\\rajmeen\\All files together\\PDF to HTML");
    jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    jfc.setSelectedFile(newFile(nameOfFile.substring(0, nameOfFile.length() - 4) + ".html"));
    jfc.showSaveDialog(PDFReader.this);
    File saveFile = jfc.getSelectedFile();
    String outputFileName = saveFile.toString();
    try {/*from w  w  w  . ja va  2  s. c  o  m*/
        ListExtraction list = new ListExtraction(outputFileName, 2, 2);
        PDFTextStripperByArea stripper = new PDFTextStripperByArea();
        stripper.setSortByPosition(true);
        stripper.addRegion("class1", rectangle);
        List allPages = document.getDocumentCatalog().getAllPages();
        PDPage firstPage = (PDPage) allPages.get(currentPage);
        stripper.extractRegions(firstPage);
        System.out.println("Text in the area:" + rectangle);
        String region = stripper.getTextForRegion("class1");
        System.out.println(region);
        List<TextPosition> TextinArea = stripper.getAllSelectedText();
        for (Iterator<TextPosition> it = TextinArea.iterator(); it.hasNext();) {
            TextPosition text = it.next();
            list.processTextt(text);
        }
        //            list.endOfTable();
        list.closeFile();
    } catch (Exception e) {
        System.err.println("Filed to convert Pdf to Html.");
    }
}

From source file:pdfreader.PDFReader.java

private void converttoTable(java.awt.event.ActionEvent evt) throws IOException, CryptographyException {

    JFileChooser jfc = new JFileChooser("G:/From Fuad sir DOCX to PDF");
    jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    jfc.setSelectedFile(newFile(nameOfFile.substring(0, nameOfFile.length() - 4) + ".html"));
    jfc.showSaveDialog(PDFReader.this);

    int[] regioon = null;
    ExtractTextByArea ETB = new ExtractTextByArea();
    try {//  w  w  w  .j  a  v  a 2  s. com
        regioon = ETB.extractTextByArea(name, rectangle, currentPage, 0);
    } catch (IOException | CryptographyException ex) {
        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
    }
    int positionOfRowStart[] = ETB.getPointOfRowStart();
    int numberofRows = ETB.returnNumberofRows();
    int numberofColumns = ETB.returnNumberofColumns();

    ExtractTextByColumn ETBC = new ExtractTextByColumn();
    Rectangle[] ColumnWiseRect = new Rectangle[(numberofColumns - 1) * numberofRows];
    int q = 0;
    for (int row = 0; row <= numberofRows - 1; row++) {
        for (int column = 0; column < numberofColumns - 1; column++) {
            if (column == 0 && row == 0) {
                ColumnWiseRect[q] = new Rectangle(rectangle.x, rectangle.y,
                        (regioon[column + 1] * 5 - rectangle.x) - 2, positionOfRowStart[row] - rectangle.y);
                //                    pdfPagePanel.drawrect(rectangle.x,rectangle.y,(regioon[column+1]*5-rectangle.x)-2,positionOfRowStart[row]-rectangle.y);
                //                    System.out.println("Cell["+row+"]["+column+"]:--"+ColumnWiseRect[q].x+","+ColumnWiseRect[q].y+","+ColumnWiseRect[q].width+","+ColumnWiseRect[q].height);
                //                    try {
                //                        ETBC.ExtractTextByArea(name,ColumnWiseRect[q],currentPage,row,column);
                //                    } catch (IOException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    } catch (CryptographyException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    }
            } else if (row == 0 && column > 0) {
                ColumnWiseRect[q] = new Rectangle(regioon[column] * 5 - 2, rectangle.y,
                        (regioon[column + 1] * 5 - regioon[column] * 5), positionOfRowStart[row] - rectangle.y);
                //                    pdfPagePanel.drawrect(regioon[column]*5-2,rectangle.y,(regioon[column+1]*5-regioon[column]*5),positionOfRowStart[row]-rectangle.y);
                //                    System.out.println("Cell["+row+"]["+column+"]:--"+ColumnWiseRect[q].x+","+ColumnWiseRect[q].y+","+ColumnWiseRect[q].width+","+ColumnWiseRect[q].height);
                //                    try {
                //                        ETBC.ExtractTextByArea(name,ColumnWiseRect[q],currentPage,row,column);
                //                    } catch (IOException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    } catch (CryptographyException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    }
            } else if (column == 0 && row > 0) {
                ColumnWiseRect[q] = new Rectangle(rectangle.x, positionOfRowStart[row - 1],
                        (regioon[column + 1] * 5 - rectangle.x),
                        (positionOfRowStart[row] - positionOfRowStart[row - 1]));
                //                    pdfPagePanel.drawrect(rectangle.x,positionOfRowStart[row-1]+2,(regioon[column+1]*5-rectangle.x),(positionOfRowStart[row]-positionOfRowStart[row-1]));
                //                    System.out.println("Cell["+row+"]["+column+"]:--"+ColumnWiseRect[q].x+","+ColumnWiseRect[q].y+","+ColumnWiseRect[q].width+","+ColumnWiseRect[q].height);
                //                    try {
                //                        ETBC.ExtractTextByArea(name,ColumnWiseRect[q],currentPage,row,column);
                //                    } catch (IOException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    } catch (CryptographyException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    }
            } else if (column > 0 && row > 0) {
                ColumnWiseRect[q] = new Rectangle(regioon[column] * 5 - 2, positionOfRowStart[row - 1],
                        (regioon[column + 1] * 5 - regioon[column] * 5),
                        (positionOfRowStart[row] - positionOfRowStart[row - 1]));
                //                    pdfPagePanel.drawrect(regioon[column]*5-2,positionOfRowStart[row-1]+2,(regioon[column+1]*5-regioon[column]*5),(positionOfRowStart[row]-positionOfRowStart[row-1]));
                //                    System.out.println("Cell["+row+"]["+column+"]:--"+ColumnWiseRect[q].x+","+ColumnWiseRect[q].y+","+ColumnWiseRect[q].width+","+ColumnWiseRect[q].height);
                //                    try {
                //                        ETBC.ExtractTextByArea(name,ColumnWiseRect[q],currentPage,row,column);
                //                    } catch (IOException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    } catch (CryptographyException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    }
            }
            q++;
        }
    }

    //        pdfPagePanel.pdfpagepanelrec = ColumnWiseRect;
    //        try {
    //            ETBC.getTable(numberofRows,numberofColumns,saveFile,true);
    //        } catch (IOException ex) {
    //            Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
    //        }        
}

From source file:pdfreader.PDFReader.java

private void converttoList(java.awt.event.ActionEvent evt) throws IOException, CryptographyException {

    JFileChooser jfc = new JFileChooser("G:/From Fuad sir DOCX to PDF");
    jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    jfc.setSelectedFile(newFile(nameOfFile.substring(0, nameOfFile.length() - 4) + ".html"));
    jfc.showSaveDialog(PDFReader.this);
    File saveFile = jfc.getSelectedFile();
    int[] regioon = null;
    ExtractTextByArea ETB = new ExtractTextByArea();
    try {//from   w  w w .j a  va 2s .  co m
        regioon = ETB.extractTextByArea(name, rectangle, currentPage, 0);
    } catch (IOException | CryptographyException ex) {
        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
    }
    int positionOfRowStart[] = ETB.getPointOfRowStart();
    int numberofRows = ETB.returnNumberofRows();
    int numberofColumns = ETB.returnNumberofColumns();

    ExtractTextByColumn ETBC = new ExtractTextByColumn();
    Rectangle[] ColumnWiseRect = new Rectangle[(numberofColumns - 1) * numberofRows];
    int q = 0;
    for (int row = 0; row <= numberofRows - 1; row++) {
        for (int column = 0; column < numberofColumns - 1; column++) {
            if (column == 0 && row == 0) {
                ColumnWiseRect[q] = new Rectangle(rectangle.x, rectangle.y,
                        (regioon[column + 1] * 5 - rectangle.x) - 2, positionOfRowStart[row] - rectangle.y);
                //                    pdfPagePanel.drawrect(rectangle.x,rectangle.y,(regioon[column+1]*5-rectangle.x)-2,positionOfRowStart[row]-rectangle.y);
                //                    System.out.println("Cell["+row+"]["+column+"]:--"+ColumnWiseRect[q].x+","+ColumnWiseRect[q].y+","+ColumnWiseRect[q].width+","+ColumnWiseRect[q].height);
                //                    try {
                //                        ETBC.ExtractTextByArea(name,ColumnWiseRect[q],currentPage,row,column);
                //                    } catch (IOException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    } catch (CryptographyException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    }
            } else if (row == 0 && column > 0) {
                ColumnWiseRect[q] = new Rectangle(regioon[column] * 5 - 2, rectangle.y,
                        (regioon[column + 1] * 5 - regioon[column] * 5), positionOfRowStart[row] - rectangle.y);
                //                    pdfPagePanel.drawrect(regioon[column]*5-2,rectangle.y,(regioon[column+1]*5-regioon[column]*5),positionOfRowStart[row]-rectangle.y);
                //                    System.out.println("Cell["+row+"]["+column+"]:--"+ColumnWiseRect[q].x+","+ColumnWiseRect[q].y+","+ColumnWiseRect[q].width+","+ColumnWiseRect[q].height);
                //                    try {
                //                        ETBC.ExtractTextByArea(name,ColumnWiseRect[q],currentPage,row,column);
                //                    } catch (IOException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    } catch (CryptographyException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    }
            } else if (column == 0 && row > 0) {
                ColumnWiseRect[q] = new Rectangle(rectangle.x, positionOfRowStart[row - 1],
                        (regioon[column + 1] * 5 - rectangle.x),
                        (positionOfRowStart[row] - positionOfRowStart[row - 1]));
                //                    pdfPagePanel.drawrect(rectangle.x,positionOfRowStart[row-1]+2,(regioon[column+1]*5-rectangle.x),(positionOfRowStart[row]-positionOfRowStart[row-1]));
                //                    System.out.println("Cell["+row+"]["+column+"]:--"+ColumnWiseRect[q].x+","+ColumnWiseRect[q].y+","+ColumnWiseRect[q].width+","+ColumnWiseRect[q].height);
                //                    try {
                //                        ETBC.ExtractTextByArea(name,ColumnWiseRect[q],currentPage,row,column);
                //                    } catch (IOException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    } catch (CryptographyException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    }
            } else if (column > 0 && row > 0) {
                ColumnWiseRect[q] = new Rectangle(regioon[column] * 5 - 2, positionOfRowStart[row - 1],
                        (regioon[column + 1] * 5 - regioon[column] * 5),
                        (positionOfRowStart[row] - positionOfRowStart[row - 1]));
                //                    pdfPagePanel.drawrect(regioon[column]*5-2,positionOfRowStart[row-1]+2,(regioon[column+1]*5-regioon[column]*5),(positionOfRowStart[row]-positionOfRowStart[row-1]));
                //                    System.out.println("Cell["+row+"]["+column+"]:--"+ColumnWiseRect[q].x+","+ColumnWiseRect[q].y+","+ColumnWiseRect[q].width+","+ColumnWiseRect[q].height);
                //                    try {
                //                        ETBC.ExtractTextByArea(name,ColumnWiseRect[q],currentPage,row,column);
                //                    } catch (IOException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    } catch (CryptographyException ex) {
                //                        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
                //                    }
            }
            q++;
        }
    }

    //pdfPagePanel.pdfpagepanelrec = ColumnWiseRect;
    try {
        ETBC.getList(numberofRows, numberofColumns, saveFile);
    } catch (IOException ex) {
        Logger.getLogger(PageWrapper.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:pl.edu.pw.appt.GUI.java

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Zapisz plik jako...");

    FileNameExtensionFilter xmlfilter = new FileNameExtensionFilter("Pliki UMLDump (*.umldump)", "umldump");
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setFileFilter(xmlfilter);

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss");
    fileChooser.setSelectedFile(new File(df.format(new Date())));

    int userSelection = fileChooser.showSaveDialog(this);
    if (userSelection == JFileChooser.APPROVE_OPTION) {
        File fileToSave = fileChooser.getSelectedFile();
        if (!FilenameUtils.getExtension(fileToSave.getName()).equalsIgnoreCase("umldump")) {
            fileToSave = new File(fileToSave.getParentFile(),
                    FilenameUtils.getBaseName(fileToSave.getName()) + ".umldump");
        }/*from  ww  w. j  av  a2  s  . c o  m*/
        try {
            FileHandler.saveFile(Paths.get(fileToSave.getAbsolutePath()),
                    server.messages.toString(selectSystem.getSelectedItem().toString()));
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Nie udao si zapisa pliku.", "Wystpi bd",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
}

From source file:pl.edu.pw.appt.GUI.java

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setDialogTitle("Zapisz obraz jako...");

    FileNameExtensionFilter xmlfilter = new FileNameExtensionFilter("Pliki BMP (*.bmp)", "bmp");
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setFileFilter(xmlfilter);

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd_hh-mm-ss");
    fileChooser.setSelectedFile(new File(df.format(new Date())));

    int userSelection = fileChooser.showSaveDialog(this);
    if (userSelection == JFileChooser.APPROVE_OPTION) {
        File fileToSave = fileChooser.getSelectedFile();
        if (!FilenameUtils.getExtension(fileToSave.getName()).equalsIgnoreCase("bmp")) {
            fileToSave = new File(fileToSave.getParentFile(),
                    FilenameUtils.getBaseName(fileToSave.getName()) + ".bmp");
        }/*from ww  w.  ja  va  2 s  .  c o m*/
        try {
            ImageIO.write((RenderedImage) image, "bmp", fileToSave);
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, "Nie udao si zapisa obrazu.", "Wystpi bd",
                    JOptionPane.ERROR_MESSAGE);
        }
    }
}