Something weird when Manually put the file path in JFileChooser

Here are the steps I got the result
1. copy one file to another directory (copy d:\log\aaa.txt d:\aaa.txt)
2. open the JFileChooser dialog box
3. change to one of the directory in 1. (here I say d:\)
4. click on aaa.txt, and click on it again after 2 sec., and then the name is editable.
5. Ctrl - c to copy the file name ("aaa.txt")
6. key in the path "d:\log\" into the "File Name:" box
7. Ctrl - v to paste the file name "aaa.txt" in to "File Name:" box, so the path name is "d:\log\aaa.txt" now
8. click OK
9. nothing happens...... cannot get the file from JFileChooser after that.
has anyone experienced this problem?
Thanks
Jeffrey

Here is the code. Thanks!!
import javax.swing.*;
import java.io.*;
class test extends JFrame
  public test(JFrame root)
    JFileChooser jfc = new JFileChooser();
    jfc.setMultiSelectionEnabled(true);
    jfc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    if (jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
      File[] files = jfc.getSelectedFiles();
      if (files != null) {
        System.out.println(files[0]);
    } else {
      System.out.println("Cancelled.");
  public static void main(String[] args)
    JFrame frame = new JFrame("test");
    new test(frame);
    frame.dispose();
    System.exit(0);
}

Similar Messages

  • Can I put the file path on remote host in the class path?

    Like this:
    java -cp "http://www.webserver.net/test/test.jar" TestClass
    Is it possible?

    I've tried it, it seems not work.Yes - as far as I know you can't specify the classpath as anything but files and folders. That's more or less what the documentation says. URLs aren't either, so I guess they're out.
    There is a URLClassLoader which may or may not be useful for you. There is a discussion of class/resource loading generally and loading remotely here: http://java.sun.com/developer/technicalArticles/Networking/classloaders/

  • Can i play Pc games on my macbook, when i put the game in no auto install comes up and can't find a file to manual install the game. HELP

    Can i play Pc games on my macbook, when i put the game in no auto install comes up and can't find a file to manual install the game. HELP

    Mozza1989 wrote:
    do i have to buy a windows version if i use bootcamp
    Of course.  Did you think Microsoft just gives it away?

  • I used a third party programme called Mackeeper UGHHH,it moved loads of files to the trash now i do not know where they originally came from or belong!! the put back option is in grey??how can i manually put these files back where they belong?SO upset!!

    I used a third party programme called Mackeeper UGHHH SOOO Stupid i know,it moved loads of files to the trash now i do not know where they originally came from or belong!! the put back option is in grey??and will not work even when i highlight one by one!!
    how can i manually put these files back where they belong?
    i know i should have used time machine but i have not set it up and its too late for that now
    i have been researching and racking my brain on how to put these folders and contents of them back to where they once were all of the contents of the folder are still in tact AND i have not emptied my trash,my programmes and some of my apps are not working properly now...i use my computer alot for making music and things are jumbled up now...
    is there anyone out there who knows the answer to my prayers on how to go about putting these folders/files back to where they came from to restore functionality to my mac..Yes and thank u if u were going to tell me i HAVE un installed mackeeper...A very sad and upset Mac user!! Cheers Shane

    hello there thank u so much for ur reply!! ok i uninstalled mackeeper now and the put back option is still in grey im so confused...i tried restarting my computer like u said and put back still in grey??!! the files that are in my trash are everything from Accounts,address book plug-ins,address book,adobe,aim.........then stuff like apple,Audio,....to caches color pickers,colors,com.apple.TCC,to DVD player to facebook,google to ilifemedia browser to itunes to keychains to movie effects,preferences printers to skype...my Native instruments files BUT not all of them my garage band but not all of it...it seriously looks like my whole library is in the trash i tried to put things back where i THINK they belong and it just added the item or folder under where i thought it went and didnt restore functionality to for instance google chrome and all my book marks are there....they seem to be only certain things from my library that would have added some functionality to apps and programmes like my garageband is missing stuff photobooth wont work so on.......kinda looks a bit like this thats only the half of it!! Cheers shane!!!

  • I have some stuff i want to put on external hard drive when i drag the file or files it just puts them back

    i have some stuff i want to put on external hard drive when i drag the file or files it just puts them back

    Did you format the external disk on Windows? If you did this, probably the external disk is formatted in NTFS. OS X can't write on this format, so it's normal that it doesn't allow you to copy the files.
    In this case, you have three possibilities:
    1. Install Paragon NTFS. This program allows you to write on NTFS partitions.
    2. Copy the hard drive content to your internal disk and format the external disk with Mac OS Extended (Journaled). Do it only if you are going to use the external disk only with OS X.
    3. The same as the last one but formatting it with exFAT. This filesystem is compatible with Windows (XP, Vista, 7, 8) and OS X (10.6.5 and newer), so you can write and read files on external disks formatted with it on Windows and OS X, but you may have problems on Linux

  • How to validate the file path when downloading.

    Hi
    How to validate the file path when downloading to Presentation or application Server.

    hiii
    you can validate file path by following way
    REPORT zvalidate.
    TYPE-POOLS: abap.
    DATA: w_direc TYPE string.
    DATA: w_bool TYPE abap_bool.
    w_dir = 'c:\Myfolder\'.
    CALL METHOD cl_gui_frontend_services=>directory_exist
    EXPORTING
    directory = w_direc
    RECEIVING
    result = w_bool
    EXCEPTIONS
    cntl_error = 1
    error_no_gui = 2
    wrong_parameter = 3
    not_supported_by_gui = 4
    OTHERS = 5.
    IF NOT w_bool IS INITIAL.
    WRITE:/ 'Directory exists.'.
    ELSE.
    WRITE:/ 'Directory does not exist.'.
    ENDIF.
    regards
    twinkal

  • I have a avchd file approx 15min in lenght on a sdhc card. My camera says there is one file. When I put the card in the PC ( Win8.1), the PC says there are 2 files,

    I have a avchd file approx 15min in length on a sdhc card. My camera says there is one file. When I put the card in the PC ( Win8.1), the PC says there are 2 files, one is 11mins approx and the other is 4mins long approx. If I bring these files into premier CS6 they are both identical length of 15mins What is going on here??

    Hi and thanks... kinda getting there but still unsure WTF. I have found that the files are split at 197gb (consistent with other uses on the web), however when I import them into premier cs6 they are 15mins and 29secs, on the SDHC card the file size is 197gbfor the larger, then the shorter one is 634mb. BUT when I import both files into premier cs6 they are identical size and length both are 15.29.19 or 15mins 29sec and 19frames. I have put the card in the camera and run that as an external and it sees the files as 2 split files while if I view the files straight off the camera there is only 1 file. Why it says there are 2 files of different sizes and premier imports them as 2 identical files is a mystery to me! I have also gone back and looked at some archived  footage on another card and yes there was one split file when the size exceeded 197gb but of course when I imported that footage nothing was missing because cs6 imported the file as a complete 'take' of the whole length

  • I have photoshop elements 10 and when I put the 1st disc in it will not load it just launches. I have gone through the step and troubleshooting in the manual but no dices please help.

    I have photoshop elements 10 and when I put the 1st disc in it will not load it just launches. I have gone through the step and troubleshooting in the manual but no dices please help.

    Hi,
    You can download Photoshop Elements 10 from the link below and Install with the serial number,
    http://helpx.adobe.com/photoshop-elements/kb/photoshop-elements-10-11-downloads.html
    Thank you

  • How can i keep adding files to a dvd on my iMac?  it keeps locking the disc when i put a file on it by saying the disc is full

    how can i keep adding files to a dvd on my iMac?  it keeps locking the disc when i put a file on it by saying the disc is ful

    Take a look at this link, https://discussions.apple.com/thread/2079043

  • I plugged my usb cable connected with my iphone 4 to the computer, and then it shows up as Iphone, but there is no button to sync, and when i manually drag the files into the storage it would say "Device is no longer responding" and it just would not work

    I plugged my usb cable connected with my iphone 4 to the computer, and then it shows up as Iphone, but there is no button to sync, and when i manually drag the files into the storage it would say "Device is no longer responding" and it just would not work... Please help me and quick

    You need to check out the User Guide here: http://manuals.info.apple.com/en_US/iphone_user_guide.pdf

  • Copying the file path of a file

    Hi when I do Get Info for a file, I can see the search path, but I cannot copy to the clipboard so I'm left with having to type it manually. Is there a better way?

    Here's some AppleScript code that will put the posix path into the clipboard. Open the AppleScript Script Editor and copy the following code into the Editor.
    --PosixPath.app
    on open drop_file
    set posix_file to POSIX path of drop_file
    set the clipboard to posix_file
    display dialog posix_file
    end open
    Now save this as an application. Drag a file onto the application icon and the posix path will be copied to the clipboard.
    Message was edited by: Mark Jalbert

  • How to get the file path in adf application

    hii all,
    i have a txt file that i am using in my adf application,
    i am passing this txt file through a File Reader, for which i have to mention the file path.
    The file is in web-content and when i am hard coding the complete file path i.e C:/JDeveloper/myApp/ViewController/public_html/log.txt
    the application is working fine when run on integrated weblogic server.
    My requirement is to access this file without giving the static file path, as in case i have to use this application on any other machine..
    for that how to mention the file path-
    i tried using FacesContext to get the context path :-
    FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
    which gives me
    \myApp-ViewController-context-root
    after appending public_html\log.txt
    I am using the following path to access the file :-
    \myApp-ViewController-context-root\public_html\log.txt
    again i am getting the java.io.FileNotFoundException
    Does anyone know how to use file from inside the web-content without giving the complete path..???
    Thanks

    Hi,
    If you put your file under public_html folder, you can use this code to access the file:
    For example file is : log.txt
    FacesContext.getCurrentInstance().getExternalContext().getRealPath('/log.txt').toString().trim();
    Thanks.
    - LSR

  • We transferred purchases / synced an iPod touch to a toshiba laptop, and then updated the ipod. we can no longer put the files back onto the ipod. what are we doing wrong]

    we transferred purchases and synced from a iPod touch to a toshiba laptop, after it updated and synced again we have been unable to put the files back onto the ipod. the computer will not let us drag or copy paste files, and when we tried to " export" the library to the documents folder, it only showed up in code.  we have books and music we would like to reload to the ipod.

    Hello Jean164,
    Thank you for using Apple Support Communities!
    It sounds like you are unable to manually put your content back on your iPod Touch.
    It seems like you may need to re enable Manually Manage Music now that the device has been updated, and this article should help with that.
    Managing content manually on iPhone, iPad, and iPod
    http://support.apple.com/kb/HT1535
    Cheers,
    Sterling

  • Issue with Getting the file path from InputFile component

    Hi,
    One of our requirement is like below:
    I am working on ADF 11g (latest release R1) page. User will select the file and when he/she clicks on the Save button we need to store the file path in the database.
    In the database file_path is varchar2(300). We need to store just the file path. I am using InputFile component but filepath is not getting inserted.
    This is really urgent. It would be really appreciate if anyone can guide me on this.
    Thanks
    MC

    Hi Mahesh,
    I have manage to store the file path from the InputFile component in Jdev 11g. I found the file upload script from this forum and manage to alter it so that i could save the file path to the database. But my problem is to retrieve it back to view as a document. Hope this will help you :)
    This is an example of what I have manage to save to my DB :
    (CLOB) //192.168.238.53/c$/Research/Docs/0906160744/EyeCandyLog.txt
    In my form, I save the file path first before I update the other fields. My code is something like this :
    public void uploadFile(ValueChangeEvent valueChangeEvent) {
    // Add event code here...
    InputStream in;
    FileOutputStream out;
    if(tanda == 0){
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    id = rS01Proposal.dptProposalid();
    tanda = tanda + 1;
    System.out.println("tanda"+ tanda);
    } catch (Exception ex) {
    ex.printStackTrace();
    System.out.println("id"+id);
    proposal = id.substring(6);
    System.out.println("proposal"+proposal);
    UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
    String fileUploadLoc = "//192.168.238.53/c$/Research/Docs/"+id+"/";//The place where file will saved
    //create upload directory
    boolean exists = (new File(fileUploadLoc)).exists();
    if (!exists) {
    (new File(fileUploadLoc)).mkdirs();
    if (file != null && file.getLength() > 0) {
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage("File Uploaded " + file.getFilename() +
    " (" + file.getLength() + " bytes)");
    *// extracting the file message to get the path*
    context.addMessage(valueChangeEvent.getComponent().getClientId(context), message);
    columnL = valueChangeEvent.getComponent().getClientId(context);
    column = columnL.substring(9);
    System.out.println(column);
    columnLengkap = "RS01"+column.toUpperCase();
    System.out.println("columnLengkap"+columnLengkap);
    *try {*
    out = new FileOutputStream(fileUploadLoc + "" + file.getFilename());
    in = file.getInputStream();
    *for (int bytes = 0; bytes < file.getLength(); bytes++) {*
    out.write(in.read());
    in.close();
    out.close();
    } catch (IOException e) {
    e.printStackTrace();
    } else {
    String filename = file != null ? file.getFilename() : null;
    String byteLength = file != null ? "" + file.getLength() : "0";
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage(FacesMessage.SEVERITY_WARN, " " + " " +
    filename + " (" + byteLength + " bytes)",
    null);
    context.addMessage(valueChangeEvent.getComponent().getClientId(context),
    message);
    System.out.println(fileUploadLoc+file.getFilename());
    a = fileUploadLoc+file.getFilename();
    b = b + 1;
    if (flagInsert == 0){
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    rS01Proposal.insertDoc(id,proposal,columnLengkap,a);
    flagInsert = flagInsert + 1;
    System.out.println("tanda"+ tanda);
    //session
    ProposalSession.storeCurrentProposalId(id);
    } catch (Exception ex) {
    ex.printStackTrace();
    }else{
    // update proses
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    rS01Proposal.updateDoc(id,proposal,columnLengkap,a);
    flagInsert = flagInsert + 1;
    //session
    ProposalSession.storeCurrentProposalId(id);
    System.out.println("tanda"+ tanda);
    } catch (Exception ex) {
    ex.printStackTrace();
    }

  • I converted from a PC to a Mac Mini.  I have my PC documents backed up on a DVD disk.  I have an external DVD drive connected to the Mac Mini.  I want to open them up and save them to the Mac, BUT....when I put the DVD disk in the Mac is NOT reading it!

    I converted from a PC to a Mac Mini.  I have my PC documents backed up on a DVD disk.  I have an external DVD drive connected to the Mac Mini.  I want to open these documents up from the DVD storage and save them to the Mac, BUT....when I put the DVD disk in the Mac is NOT reading it!

    Hi Joe,
    Thanks for your quick response.  I should add....it worked before.  When I previously inserted the two DVDs into this remote drive, and I went into finder, I could click on the "remote device" line and see all my saved documents (excel, word, etc) on the DVD and open them on the Mac.  Now I cannot see them, when I try to open them on the Mac, nothing happens, nothing is displayed.  I just re-tested the remote DVD drive with a CD and, no problem, it opened up the CD via iTunes and I cold play the CD.  SO......I know the remote DVD drive (it's an LG by the way) is fine, it's something to do with some settings on my mini mac,especially where I could open it previously.  I do not remember changing any settings since then. 
    When I go into system preferences and click on CD/DVD it gives me options of how to open up a music CD (default is iTunes), a DVD (default is iMovie), etc.  The problem is my DVD is all miscellaneious files/documents.  I just want to be able to see them in the finder.  I also tried to open them via microsoft word, from the remote disk and again, it could not open the drive, even though some of the documents were microsoft word documents.  Again, I was able to open them previously and the DVD is not corrupted in any way.  
    Any additional advice? 
    Thank you!

Maybe you are looking for