|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javacvs.util; import org.openide.filesystems.*; /** * * @author Martin Entlicher * @version */ public class ChooseFileObjectDialog extends javax.swing.JDialog { private FileObject dir; private String selectedFile; static final long serialVersionUID = -5051443974946619476L; /** Creates new form ChooseFileObjectDialog */ public ChooseFileObjectDialog(java.awt.Frame parent, boolean modal, FileObject dir) { super (parent, modal); this.dir = dir; setTitle(org.openide.util.NbBundle.getBundle(ChooseFileObjectDialog.class).getString("ChooseFileObjectDialog.title")); //NOI18N initComponents (); fillFileList(); pack (); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ private void initComponents() {//GEN-BEGIN:initComponents listPanel = new javax.swing.JPanel(); fileScrollPane = new javax.swing.JScrollPane(); fileList = new javax.swing.JList(); jPanel2 = new javax.swing.JPanel(); fileNameLabel = new javax.swing.JLabel(); fileNameTextField = new javax.swing.JTextField(); saveButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); getContentPane().setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints1; addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } } ); listPanel.setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints2; fileList.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { fileListMouseClicked(evt); } } ); fileScrollPane.setViewportView(fileList); gridBagConstraints2 = new java.awt.GridBagConstraints(); gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints2.weightx = 1.0; gridBagConstraints2.weighty = 1.0; listPanel.add(fileScrollPane, gridBagConstraints2); gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.insets = new java.awt.Insets(8, 8, 8, 8); gridBagConstraints1.weightx = 1.0; gridBagConstraints1.weighty = 1.0; getContentPane().add(listPanel, gridBagConstraints1); jPanel2.setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints3; fileNameLabel.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/util/Bundle").getString("ChooseFileObjectDialog.fileNameLabel.text")); gridBagConstraints3 = new java.awt.GridBagConstraints(); gridBagConstraints3.insets = new java.awt.Insets(0, 0, 0, 8); jPanel2.add(fileNameLabel, gridBagConstraints3); fileNameTextField.setColumns(10); gridBagConstraints3 = new java.awt.GridBagConstraints(); gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints3.insets = new java.awt.Insets(0, 0, 0, 8); gridBagConstraints3.weightx = 1.0; jPanel2.add(fileNameTextField, gridBagConstraints3); saveButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/util/Bundle").getString("ChooseFileObjectDialog.saveButton.text")); saveButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveButtonActionPerformed(evt); } } ); gridBagConstraints3 = new java.awt.GridBagConstraints(); gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL; jPanel2.add(saveButton, gridBagConstraints3); cancelButton.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/cvsclient/util/Bundle").getString("ChooseFileObjectDialog.cancelButton.text")); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } } ); gridBagConstraints3 = new java.awt.GridBagConstraints(); gridBagConstraints3.gridx = 2; gridBagConstraints3.gridy = 1; gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints3.insets = new java.awt.Insets(8, 0, 0, 0); gridBagConstraints3.anchor = java.awt.GridBagConstraints.EAST; jPanel2.add(cancelButton, gridBagConstraints3); gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridy = 1; gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints1.insets = new java.awt.Insets(8, 8, 8, 8); gridBagConstraints1.weightx = 1.0; getContentPane().add(jPanel2, gridBagConstraints1); }//GEN-END:initComponents private void fileListMouseClicked (java.awt.event.MouseEvent evt) {//GEN-FIRST:event_fileListMouseClicked // Add your handling code here: selectedFile = (String) fileList.getSelectedValue(); fileNameTextField.setText(selectedFile); fileNameTextField.repaint(); }//GEN-LAST:event_fileListMouseClicked private void saveButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed // Add your handling code here: selectedFile = fileNameTextField.getText(); closeDialog(null); }//GEN-LAST:event_saveButtonActionPerformed private void cancelButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed // Add your handling code here: selectedFile = null; closeDialog(null); }//GEN-LAST:event_cancelButtonActionPerformed /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog setVisible (false); dispose (); }//GEN-LAST:event_closeDialog private void fillFileList() { javax.swing.DefaultListModel model = new javax.swing.DefaultListModel(); FileObject[] ch = dir.getChildren(); for(int i = 0; i < ch.length; i++) { if (ch[i].getExt().equalsIgnoreCase("properties")) model.addElement(ch[i].getName()); //NOI18N } fileList.setModel(model); } public String getSelectedFile() { return selectedFile; } /* * @param args the command line arguments public static void main (String args[]) { new ChooseFileObjectDialog (new javax.swing.JFrame (), true).show (); } */ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel listPanel; private javax.swing.JScrollPane fileScrollPane; private javax.swing.JList fileList; private javax.swing.JPanel jPanel2; private javax.swing.JLabel fileNameLabel; private javax.swing.JTextField fileNameTextField; private javax.swing.JButton saveButton; private javax.swing.JButton cancelButton; // End of variables declaration//GEN-END:variables } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.