-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.1
-
x86
-
windows_nt
Name: pa48320 Date: 06/13/2003
Steps to reproduce:
1. Compile and run DialogTest.java. Press the button to bring up the JFileChooser.
java an.bn.DialogTest
2. Create a directory by DIR1
3. Double click to enter the directory
4. Create another directory with DIR1, say DIR2
5. Change the view type to Detail
6. Click on DIR2 to bring to rename mode
7. Now try to come out of the rename mode by clicking outside the directory
Excepted behaviour: It should come out of the rename mode
Actual behaviour: It does not come out of the rename mode(unless some other component is select within the JFileChooser)
DialogTest.java
---------------
package an.bn;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.filechooser.*;
import java.util.StringTokenizer;
public class DialogTest extends JFrame {
static private final String newline = "\n";
public DialogTest() {
super("FileChooserDemo");
//Create the log first, because the action listeners
//need to refer to it.
//Create a file chooser
final JFileChooser fc = new JFileChooser();
fc.setMultiSelectionEnabled(true);
TextFilter txt = new TextFilter();
fc.setFileFilter(txt);
fc.addChoosableFileFilter(txt);
fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
//Create the open button
JButton openButton = new JButton("Open a File...");
openButton.setMnemonic(openButton.getText().charAt(0));
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int returnVal = fc.showOpenDialog(DialogTest.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
//this is where a real application would open the file.
System.out.println("Opening: " + file.getName() + "." + newl
ine);
//StringTokenizer st = new StringTokenizer(null, " ");
StringBuffer buff = new StringBuffer("");
String ii = buff.toString();
}
else {
System.out.println("Open command cancelled by user." + newli
ne);
}
}
});
//For layout purposes, put the buttons in a separate panel
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(openButton);
//Add the buttons and the log to the frame
Container contentPane = getContentPane();
contentPane.add(buttonPanel);
}
public static void main(String[] args) {
StringBuffer tm=new StringBuffer("\"");
tm.append("THis is new");
tm.append("\"");
System.out.println(tm);
JFrame frame = new DialogTest();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
class TextFilter extends javax.swing.filechooser.FileFilter
{
public boolean accept(File f)
{
if ( f.isDirectory() || f.getName().endsWith("txt") || f.getName
().endsWith("TXT") )
return true;
else
return false;
}
public String getDescription()
{
return "Text Files";
}
}
}
(Review ID: 187803)
======================================================================
- duplicates
-
JDK-4835633 JFileChooser: problem with clicking outside of a file being renamed
-
- Resolved
-