List of usage examples for javax.swing JFileChooser SELECTED_FILE_CHANGED_PROPERTY
String SELECTED_FILE_CHANGED_PROPERTY
To view the source code for javax.swing JFileChooser SELECTED_FILE_CHANGED_PROPERTY.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) { JFileChooser chooser = (JFileChooser) evt.getSource(); File oldFile = (File) evt.getOldValue(); File newFile = (File) evt.getNewValue(); File curFile = chooser.getSelectedFile(); }/*from ww w .j av a 2s. c o m*/ } }); }
From source file:Main.java
public static void main(String[] argv) throws Exception { final JFileChooser chooser = new JFileChooser(); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) { JFileChooser chooser = (JFileChooser) evt.getSource(); File oldDir = (File) evt.getOldValue(); File newDir = (File) evt.getNewValue(); File curDir = chooser.getCurrentDirectory(); }//from www . ja va 2s .c o m } }); }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) { JFileChooser chooser = (JFileChooser) evt.getSource(); File oldFile = (File) evt.getOldValue(); File newFile = (File) evt.getNewValue(); System.out.println(oldFile); System.out.println(newFile); System.out.println(chooser.getSelectedFile()); } else if (JFileChooser.SELECTED_FILES_CHANGED_PROPERTY.equals(evt.getPropertyName())) { JFileChooser chooser = (JFileChooser) evt.getSource(); File[] oldFiles = (File[]) evt.getOldValue(); File[] newFiles = (File[]) evt.getNewValue(); Arrays.toString(oldFiles); Arrays.toString(newFiles); File[] files = chooser.getSelectedFiles(); Arrays.toString(files); }/*ww w . j a v a 2 s. c om*/ } }); chooser.setVisible(true); }
From source file:Main.java
public void propertyChange(PropertyChangeEvent evt) { if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(evt.getPropertyName())) { JFileChooser chooser = (JFileChooser) evt.getSource(); // Get the new selected file File newFile = (File) evt.getNewValue(); repaint();/* w ww. j a v a 2s. c o m*/ } }
From source file:MainClass.java
public void propertyChange(PropertyChangeEvent changeEvent) { String changeName = changeEvent.getPropertyName(); if (changeName.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { File file = (File) changeEvent.getNewValue(); if (file != null) { setText(file.getName());/* ww w. j av a 2s . c om*/ } } }
From source file:com.codecrate.shard.ui.binding.JFileChooserBinding.java
protected JComponent doBindControl() { File value = (File) getValue(); component.setSelectedFile(value);//from w w w .j a v a2 s. co m component.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { String prop = evt.getPropertyName(); if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) { File file = (File) evt.getNewValue(); controlValueChanged(file); updateLabel(file); } } }); updateLabel(value); JPanel panel = new JPanel(); panel.add(label); JButton browseButton = new JButton("Browse"); browseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { component.showDialog(getActiveWindow().getControl(), "Ok"); } }); panel.add(browseButton); return panel; }
From source file:components.ImagePreview.java
public void propertyChange(PropertyChangeEvent e) { boolean update = false; String prop = e.getPropertyName(); //If the directory changed, don't show an image. if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(prop)) { file = null;//from ww w . j av a 2 s .c o m update = true; //If a file became selected, find out which one. } else if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(prop)) { file = (File) e.getNewValue(); update = true; } //Update the preview accordingly. if (update) { thumbnail = null; if (isShowing()) { loadImage(); repaint(); } } }
From source file:FilterSample.java
public void propertyChange(PropertyChangeEvent changeEvent) { String changeName = changeEvent.getPropertyName(); if (changeName.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) { File file = (File) changeEvent.getNewValue(); if (file != null) { ImageIcon icon = new ImageIcon(file.getPath()); if (icon.getIconWidth() > PREFERRED_WIDTH) { icon = new ImageIcon( icon.getImage().getScaledInstance(PREFERRED_WIDTH, -1, Image.SCALE_DEFAULT)); if (icon.getIconHeight() > PREFERRED_HEIGHT) { icon = new ImageIcon( icon.getImage().getScaledInstance(-1, PREFERRED_HEIGHT, Image.SCALE_DEFAULT)); }/*from w w w . jav a2 s .co m*/ } setIcon(icon); } } }
From source file:AccessoryFileChooser.java
public void propertyChange(PropertyChangeEvent e) { String pname = e.getPropertyName(); if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(pname)) { // Ok, the user selected a file in the chooser File f = (File) e.getNewValue(); // Make reasonably sure it's an audio file if ((f != null) && (f.getName().toLowerCase().endsWith(".au") || f.getName().toLowerCase().endsWith(".wav") || f.getName().toLowerCase().endsWith(".aif") || f.getName().toLowerCase().endsWith(".aiff"))) { setCurrentClip(f);/*from www . j av a 2s . c o m*/ } else { setCurrentClip(null); } } }
From source file:FileChooserTest.java
/** * Constructs an ImagePreviewer./* w ww . j a va 2 s .c om*/ * @param chooser the file chooser whose property changes trigger an image change in this * previewer */ public ImagePreviewer(JFileChooser chooser) { setPreferredSize(new Dimension(100, 100)); setBorder(BorderFactory.createEtchedBorder()); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (event.getPropertyName() == JFileChooser.SELECTED_FILE_CHANGED_PROPERTY) { // the user has selected a new file File f = (File) event.getNewValue(); if (f == null) { setIcon(null); return; } // read the image into an icon ImageIcon icon = new ImageIcon(f.getPath()); // if the icon is too large to fit, scale it if (icon.getIconWidth() > getWidth()) icon = new ImageIcon( icon.getImage().getScaledInstance(getWidth(), -1, Image.SCALE_DEFAULT)); setIcon(icon); } } }); }