Example usage for javax.swing JFileChooser setDialogTitle

List of usage examples for javax.swing JFileChooser setDialogTitle

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The title of the JFileChooser dialog window.")
public void setDialogTitle(String dialogTitle) 

Source Link

Document

Sets the string that goes in the JFileChooser window's title bar.

Usage

From source file:org.pgptool.gui.ui.encryptone.EncryptOnePm.java

public ExistingFileChooserDialog getSourceFileChooser() {
    if (sourceFileChooser == null) {
        sourceFileChooser = new ExistingFileChooserDialog(findRegisteredWindowIfAny(), appProps,
                SOURCE_FOLDER) {/*from  ww  w  .jav  a  2s.  co  m*/
            @Override
            protected void doFileChooserPostConstruct(JFileChooser ofd) {
                super.doFileChooserPostConstruct(ofd);
                ofd.setDialogTitle(Messages.get("phrase.selectFileToEncrypt"));

                ofd.setAcceptAllFileFilterUsed(false);
                ofd.addChoosableFileFilter(notEncryptedFiles);
                ofd.addChoosableFileFilter(ofd.getAcceptAllFileFilter());
                ofd.setFileFilter(ofd.getChoosableFileFilters()[0]);
            }

            private FileFilter notEncryptedFiles = new FileFilter() {
                @Override
                public boolean accept(File f) {
                    return !DecryptOnePm.isItLooksLikeYourSourceFile(f.getAbsolutePath());
                }

                @Override
                public String getDescription() {
                    return text("phrase.allExceptEncrypted");
                }
            };
        };
    }
    return sourceFileChooser;
}

From source file:com.ejie.uda.jsonI18nEditor.Editor.java

public void showImportDialog() {
    String path = null;/*from  www.  ja  v  a  2s .  c  om*/
    if (resourcesDir != null) {
        path = resourcesDir.toString();
    }
    JFileChooser fc = new JFileChooser(path);
    fc.setDialogTitle(MessageBundle.get("dialogs.import.title"));
    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fc.setFileFilter(new FileNameExtensionFilter("json i18n file", "json"));
    int result = fc.showOpenDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
        importResources(Paths.get(fc.getSelectedFile().getPath()));
    }
}

From source file:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java

/**
 * This method initializes jExaminarButton   
 *    //ww w  . j a  va2 s  .c  om
 * @return javax.swing.JButton   
 */
private JButton getJExaminarButton() {
    if (jExaminarButton == null) {
        jExaminarButton = new JButton();
        jExaminarButton.setText(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_10));
        jExaminarButton.setPreferredSize(new Dimension(90, 20));
        jExaminarButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                final JFileChooser libreria = new JFileChooser();
                libreria.setDialogTitle(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_11));
                int returnVal = libreria.showOpenDialog(jPanel);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    jLibreriaTextField.setText(libreria.getSelectedFile().toString());
                }
            }
        });
    }
    return jExaminarButton;
}

From source file:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java

/**
 * This method initializes jExaminarButton1   
 *    //from   ww  w.j  a va2  s .c  o  m
 * @return javax.swing.JButton   
 */
private JButton getJExaminarButton1() {
    if (jExaminarButton1 == null) {
        jExaminarButton1 = new JButton();
        jExaminarButton1.setPreferredSize(new Dimension(90, 20));
        jExaminarButton1.setText(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_10));
        jExaminarButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                final JFileChooser libreria = new JFileChooser();
                libreria.setDialogTitle(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_11));
                int returnVal = libreria.showOpenDialog(jPanel);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    jNuevaLibreriaTextField.setText(libreria.getSelectedFile().toString());
                }
            }
        });
    }
    return jExaminarButton1;
}

From source file:com.akman.excel.view.frmExportExcel.java

private void btnSelectImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectImageActionPerformed
    JFileChooser chooser = new JFileChooser();

    FileNameExtensionFilter filter = new FileNameExtensionFilter("Image files", "jpg", "png", "gif", "bmp");
    chooser.setFileFilter(filter);/*w ww.j  a va2  s .co  m*/

    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setDialogTitle("Select The Image");
    chooser.setMultiSelectionEnabled(false);
    int res = chooser.showOpenDialog(null);
    if (res == JFileChooser.APPROVE_OPTION) {

        //Saving file inside the file
        File file = chooser.getSelectedFile();

        //        if(!file.equals(filter))
        //        {
        //        JOptionPane.showMessageDialog(null, "Wrong File Selected","ERROR",JOptionPane.ERROR_MESSAGE);
        //        return;
        //        }
        //System.out.println(file.getAbsolutePath());
        ImageIcon image = new ImageIcon(file.getAbsolutePath());

        fileNameSignature = file.getAbsolutePath();

        // Get Width And Height of PicLabel
        Rectangle rect = lblImage.getBounds();

        //System.out.println(lblImage.getBounds());
        //Scaling the image to fit in the picLabel
        Image scaledimage = image.getImage().getScaledInstance(rect.width, rect.height, Image.SCALE_DEFAULT);
        //converting the image back to image icon to make an acceptable picLabel
        image = new ImageIcon(scaledimage);

        lblImage.setIcon(image);

        txtPathSig.setText(fileNameSignature);

        try {

            File images = new File(fileNameSignature);

            FileInputStream fis = new FileInputStream(images);

            ByteArrayOutputStream bos = new ByteArrayOutputStream();

            byte[] buf = new byte[1024];

            for (int readNum; (readNum = fis.read(buf)) != -1;) {
                bos.write(buf, 0, readNum);
            }

            person_image = bos.toByteArray();

        } catch (Exception e) {

            JOptionPane.showMessageDialog(null, e);
        }

    }
}

From source file:fll.subjective.SubjectiveFrame.java

/**
 * Prompt the user for a file.//from w  w w .j  a  va  2s.c  o m
 * 
 * @param title the title on the chooser dialog
 * @return the file if accepted, null if canceled
 */
private File chooseSubjectiveFile(final String title) {
    final File initialDirectory = getInitialDirectory();
    final JFileChooser fileChooser = new JFileChooser(initialDirectory);
    fileChooser.setDialogTitle(title);
    fileChooser.setFileFilter(new BasicFileFilter("FLL Subjective Data Files", "fll"));
    final int state = fileChooser.showOpenDialog(this);
    if (JFileChooser.APPROVE_OPTION == state) {
        final File file = fileChooser.getSelectedFile();
        setInitialDirectory(file);
        return file;
    } else {
        return null;
    }
}

From source file:it.staiger.jmeter.protocol.http.config.gui.DynamicFilePanel.java

/**
 * opens a dialog box to choose a file and returns selected file's
 * folder.//from ww  w  . j  a v a 2s  .  co m
 *
 * @return a new File object of selected folder
 */
private String browseAndGetFolderPath() {
    String path = folder.getText();
    if (path.isEmpty())
        path = FileDialoger.getLastJFCDirectory();
    JFileChooser chooser = new JFileChooser(new File(path));

    chooser.setDialogTitle("select folder");// $NON-NLS-1$
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);
    if (chooser.showOpenDialog(GuiPackage.getInstance().getMainFrame()) == JFileChooser.APPROVE_OPTION) {
        path = chooser.getSelectedFile().getAbsolutePath();
        FileDialoger.setLastJFCDirectory(path);
    }
    return path;
}

From source file:com.akman.excel.view.frmExportExcel.java

private void btnAddFileActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnAddFileActionPerformed
{//GEN-HEADEREND:event_btnAddFileActionPerformed

    JFileChooser chooser = new JFileChooser();

    FileNameExtensionFilter filter = new FileNameExtensionFilter("Excel files", "xlsx", "xlsm", "xlt", "xlsb",
            "xltx", "xltm", "xls", "xlt", "xls");

    chooser.setFileFilter(filter);/*from   w w  w  . j  a v a2  s . com*/
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setDialogTitle("Select The Image");
    chooser.setMultiSelectionEnabled(false);

    int res = chooser.showOpenDialog(null);

    if (res == JFileChooser.APPROVE_OPTION) {

        File file = chooser.getSelectedFile();

        // checking file extension. it must be excel file. 
        if (file.equals(filter)) {
            JOptionPane.showMessageDialog(null, "Wrong File selected", "ERROR", JOptionPane.ERROR_MESSAGE);
            return;
        }

        fileName = file.getAbsolutePath();
        txtPath.setText(fileName);

    }

}

From source file:cn.labthink.ReadAccess060.java

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

    //filter/*from w  w w .  j a va 2 s .co m*/
    ExtensionFileFilter filter = new ExtensionFileFilter("mdb", false, true);
    filter.setDescription("Open DataBase File");
    //?

    JFileChooser jfc = new JFileChooser();

    FileSystemView fsv = FileSystemView.getFileSystemView();
    //?
    jfc.setCurrentDirectory(fsv.getHomeDirectory());

    jfc.setDialogTitle("Choose the mdb file");
    jfc.setMultiSelectionEnabled(false);
    jfc.setDialogType(JFileChooser.OPEN_DIALOG);
    jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    jfc.setFileFilter(filter);
    int result = jfc.showOpenDialog(this); // ""?
    if (result == JFileChooser.APPROVE_OPTION) {
        String filesrc = jfc.getSelectedFile().getAbsolutePath();
        inputfile = jfc.getSelectedFile();
        jLabel_dbpath.setText("DB File Path:" + filesrc);
        maxid = Integer.MIN_VALUE;
        minid = Integer.MAX_VALUE;
    } else {
        return;
    }
    //

    Infodata = new Vector();
    Infocolumns = new Vector();

    try {

        //            String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D://b.MDB";
        if (inputfile == null) {
            return;
        }
        initDB();

        sql = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        rs = sql.executeQuery("SELECT * FROM test order by testid desc");

        Infocolumns.add("TestID");
        Infocolumns.add("TestType");
        Infocolumns.add("DeviceID");
        Infocolumns.add("CellID");
        Infocolumns.add("Operator");
        Infocolumns.add("StartTime");
        Infocolumns.add("EndTime");
        Infocolumns.add("Comments");
        Infocolumns.add("SetTemp.");
        int columnCount = Infocolumns.size();
        Vector row;
        while (rs.next()) {
            row = new Vector(columnCount);
            int temp = 0;
            int ivalue = rs.getInt("TESTID");
            maxid = maxid < ivalue ? ivalue : maxid;
            minid = minid > ivalue ? ivalue : minid;
            row.add(ivalue);
            temp = rs.getInt("TESTTYPE");
            if (temp == 1) {
                row.add("OTR");
            } else if (temp == 2) {
                row.add("WVTR");
            } else {
                row.add(temp);
            }
            row.add(rs.getInt("DEVICEID"));
            row.add(rs.getString("CELLID"));
            row.add(rs.getString("OPERATOR"));
            row.add(rs.getDate("STARTTIME"));
            row.add(rs.getDate("ENDTIME"));
            row.add(rs.getString("COMMENTS"));
            row.add(rs.getDouble("SETTEMP"));
            //                row.add(rs.getString(11));
            //                row.add(rs.getInt(10));
            Infodata.add(row);
        }

        DefaultTableModel tableModel = new DefaultTableModel(Infodata, Infocolumns);
        jTable1.setModel(tableModel);
        //?  
        // jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);  
        jTable1.setSelectionBackground(Color.orange);
        //?
        TableRowSorter<TableModel> tableRowSorter = new TableRowSorter<TableModel>(tableModel);
        jTable1.setRowSorter(tableRowSorter);
        //            jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        //table
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// table
        tcr.setHorizontalAlignment(SwingConstants.CENTER);// ??
        jTable1.setDefaultRenderer(Object.class, tcr);

        //
        ((DefaultTableCellRenderer) jTable1.getTableHeader().getDefaultRenderer())
                .setHorizontalAlignment(SwingConstants.CENTER);
        //            DefaultTableCellRenderer  rh = new DefaultTableCellRenderer();
        //            rh.setHorizontalAlignment(SwingConstants.CENTER);
        //            jTable1.getTableHeader().setDefaultRenderer(rh);

        jTable1.getColumnModel().getColumn(0).setPreferredWidth(20);
        jTable1.getColumnModel().getColumn(1).setPreferredWidth(28);
        jTable1.getColumnModel().getColumn(2).setPreferredWidth(20);
        jTable1.getColumnModel().getColumn(3).setPreferredWidth(40);
        jTable1.getColumnModel().getColumn(4).setPreferredWidth(40);
        jTable1.getColumnModel().getColumn(5).setPreferredWidth(100);
        jTable1.getColumnModel().getColumn(6).setPreferredWidth(100);
        jTable1.getColumnModel().getColumn(7).setPreferredWidth(100);

    } catch (SQLException ee) {
        System.out.println(ee);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(ReadAccess060.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            sql.close();
        } catch (Exception e) {
        }
        try {
            rs.close();
        } catch (Exception e) {
        }
    }

    //        validate();

}

From source file:cn.labthink.ReadAccess330.java

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

    //filter//from  w ww .  j av a  2 s. co m
    ExtensionFileFilter filter = new ExtensionFileFilter("mdb", false, true);
    filter.setDescription("Open DataBase File");
    //?

    JFileChooser jfc = new JFileChooser();

    FileSystemView fsv = FileSystemView.getFileSystemView();
    //?
    jfc.setCurrentDirectory(fsv.getHomeDirectory());

    jfc.setDialogTitle("Choose the mdb file");
    jfc.setMultiSelectionEnabled(false);
    jfc.setDialogType(JFileChooser.OPEN_DIALOG);
    jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
    jfc.setFileFilter(filter);
    int result = jfc.showOpenDialog(this); // ""?
    if (result == JFileChooser.APPROVE_OPTION) {
        String filesrc = jfc.getSelectedFile().getAbsolutePath();
        inputfile = jfc.getSelectedFile();
        jLabel_dbpath.setText("DB File Path:" + filesrc);
        maxid = Integer.MIN_VALUE;
        minid = Integer.MAX_VALUE;
    } else {
        return;
    }
    //

    Infodata = new Vector();
    Infocolumns = new Vector();

    try {

        //            String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=D://b.MDB";
        if (inputfile == null) {
            return;
        }
        initDB();

        sql = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
        rs = sql.executeQuery("SELECT * FROM test order by testid desc");

        Infocolumns.add("TestID");
        Infocolumns.add("TestType");
        Infocolumns.add("DeviceID");
        Infocolumns.add("CellID");
        Infocolumns.add("Operator");
        Infocolumns.add("StartTime");
        Infocolumns.add("EndTime");
        Infocolumns.add("Comments");
        Infocolumns.add("SetTemp.");
        int columnCount = Infocolumns.size();
        Vector row;
        while (rs.next()) {
            row = new Vector(columnCount);
            int temp = 0;
            int ivalue = rs.getInt("TESTID");
            maxid = maxid < ivalue ? ivalue : maxid;
            minid = minid > ivalue ? ivalue : minid;
            row.add(ivalue);
            temp = rs.getInt("TESTTYPE");
            if (temp == 1) {
                row.add("OTR");
            } else if (temp == 2) {
                row.add("WVTR");
            } else {
                row.add(temp);
            }
            row.add(rs.getInt("DEVICEID"));
            row.add(rs.getString("CELLID"));
            row.add(rs.getString("OPERATOR"));
            row.add(rs.getDate("STARTTIME"));
            row.add(rs.getDate("ENDTIME"));
            row.add(rs.getString("COMMENTS"));
            row.add(rs.getDouble("SETTEMP"));
            //                row.add(rs.getString(11));
            //                row.add(rs.getInt(10));
            Infodata.add(row);
        }

        DefaultTableModel tableModel = new DefaultTableModel(Infodata, Infocolumns);
        jTable1.setModel(tableModel);
        //?  
        // jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);  
        jTable1.setSelectionBackground(Color.orange);
        //?
        TableRowSorter<TableModel> tableRowSorter = new TableRowSorter<TableModel>(tableModel);
        jTable1.setRowSorter(tableRowSorter);
        //            jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        //table
        DefaultTableCellRenderer tcr = new DefaultTableCellRenderer();// table
        tcr.setHorizontalAlignment(SwingConstants.CENTER);// ??
        jTable1.setDefaultRenderer(Object.class, tcr);

        //
        ((DefaultTableCellRenderer) jTable1.getTableHeader().getDefaultRenderer())
                .setHorizontalAlignment(SwingConstants.CENTER);
        //            DefaultTableCellRenderer  rh = new DefaultTableCellRenderer();
        //            rh.setHorizontalAlignment(SwingConstants.CENTER);
        //            jTable1.getTableHeader().setDefaultRenderer(rh);

        jTable1.getColumnModel().getColumn(0).setPreferredWidth(20);
        jTable1.getColumnModel().getColumn(1).setPreferredWidth(28);
        jTable1.getColumnModel().getColumn(2).setPreferredWidth(20);
        jTable1.getColumnModel().getColumn(3).setPreferredWidth(40);
        jTable1.getColumnModel().getColumn(4).setPreferredWidth(40);
        jTable1.getColumnModel().getColumn(5).setPreferredWidth(100);
        jTable1.getColumnModel().getColumn(6).setPreferredWidth(100);
        jTable1.getColumnModel().getColumn(7).setPreferredWidth(100);

    } catch (SQLException ee) {
        System.out.println(ee);
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(ReadAccess330.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            sql.close();
        } catch (Exception e) {
        }
        try {
            rs.close();
        } catch (Exception e) {
        }
    }

    //        validate();

}