JFileChooser doubt

Hi,
I was wondering how could i get the complete file path from my JFileChooser, instead of getting only the file name......
i used the .getSelectedFile().getName() methods and I only got the file's name....
does anyone know how to get the filepath along with the filename?
thanks in advance!

Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

Similar Messages

  • How to work JFileChooser

    Now i doing one program in java swing. main concept of the program is creating notepad.
    In this program I have one doubt. I created a filemenu ,within filemenu inserted Open&Save Option .But i don't know coding for Open and Save Option.
    Please Give me Sourcecode and Logic for thisProgarm

    Here is simple example. You should flesh it out. There is a corresponding JTextComponent#write() method you can use when you want to save the file.
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    public class JFileChooserTest extends JFrame {
         private JFileChooser chooser;
         private JTextArea textArea;
         public JFileChooserTest() {
              JPanel cp = new JPanel();
              textArea = new JTextArea(25, 60);
              cp.add(new JScrollPane(textArea));
              setContentPane(cp);
              JMenu menu = new JMenu("File");
              JMenuItem item = new JMenuItem("Open...");
              item.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        openFile();
              menu.add(item);
              JMenuBar menuBar = new JMenuBar();
              menuBar.add(menu);
              setJMenuBar(menuBar);
              setTitle("JFileChooser Demo");
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              pack();
         private void openFile() {
              if (chooser==null) {
                   chooser = new JFileChooser();
              int rc = chooser.showOpenDialog(this);
              if (rc==JFileChooser.APPROVE_OPTION) {
                   File file = chooser.getSelectedFile();
                   try {
                        BufferedReader r = new BufferedReader(new FileReader(file));
                        textArea.read(r, null);
                        r.close();
                   } catch (IOException ioe) {
                        UIManager.getLookAndFeel().provideErrorFeedback(this);
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        new JFileChooserTest().setVisible(true);
    }Edited by: BoBear2681 on Jul 18, 2008 1:51 PM

  • JFileChooser and FileSystemView

    I overwrote the FileSystemView class so I could add some remote system to the browser.
    I have a problem with method File[] getRoots().
    example:
    public File[] getRoots()
    File[] files = super.getRoots();
    File[] fileAll = new File[files.length+1];
    int i=0;
    for(i=0;i<files.length;i++)
    fileAll=files[i];
    File rr = new File("blabla");
    fileAll[i]=createFileSystemRoot(rr);
    return fileAll;
    it is ok - I can added root
    public File[] getRoots()
    File[] files = super.getRoots();
    File[] fileAll = new File[files.length+servers.size()];
    int i=0;
    for(i=0;i<files.length;i++)
    fileAll[i]=files[i];
    for(int j=0;j<servers.size();j++,i++)
    File rf = (File)servers.get(j);
    fileAll[i]=createFileSystemRoot(rf);
    return fileAll;
    I cannot see added roots ...
    the list is empty at the begining and it is filled later.
    I call JFileChooser.rescanCurrentDirectory();
    but it helps nothing .

    Thanks. I had not seen that particular example and will have to study it a bit more to see if I can pick up some pointers.
    Just to clarify, the issue I'm tracking down is that every thing is working fine until the user switches over to the "Details" view... At which point it appears that some of the columns in the entry for the "special" folders are missing and the date stamp shows up in the "Type" column.
    My reading of the API documents was that the FileSystemView's getSystemTypeDescription method provides the string for the Type column (i.e. "File Folder"). Alternately, the JFileChooser provides a method called getTypeDescription. Since I would have expected that my "special" folder, which is just another File object returned from FileSystemView.getFiles, would have the entry "File Folder" in the type field. When this didn't happen, I experimented with adding my own FileView, putting break points into the JFileChooser itself (using netbeans), and trying to see where the routines were called. They do not appear to be called, so I am assuming that the strings in question are formatted elsewhere in the program (however, methods such as getIcon, getName, etc are called just fine). Although I looked at the source code for JFileChooser (again, using netbeans), I did not find any obvious cause for this problem. Of course, I'm not entirely sure that the source code netbeans shows me is the code that is actually exercised at run time... I see no reason to doubt netbeans, I just don't know enough about the way it works to assume that I am using it correctly.
    g.

  • Doubt in fbl1n transaction

    hi i have a doubt....
    in fbl1n transaction, there are open items and cleared items.
    in it the cleared items  for certain document types such as invoice etc is not present in the open item table (bsik)
    however the cleared items for document types such as general  voucher its present in the open items table (bsik)
    is this possible as all cleared item entries shld b present in the open item table with an indicator set for cleared or not...
    plz exlain!

    Hi
    There are 2 tables(open and Closed Items)  in FI for Account Payables and Account Receivables and GL accounts
    1.Account payables: BSIK is Open Items and BSAK is Closed items
    2.Account Receivables; BSID and BSAD for OPEN and closed items
    3/GL accounts :  BSIS and BSAS  for Open and Closed Items
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • No Disk Error when opening JFileChooser

    Hi all
    After launching my app via JWS and opening my apps FileChooser I get a 'javaw.exe - No Disk' error message:
    'There is no disk in the drive. Please insert a disk into drive A:.'
    This doesn't happen if I start the app without JWS. Although it happens only the first time after opening the FileChooser it's rather annoying for the user. I can't expect the user always having a disk in their drive.
    Is there a way of switching the scan for drive A off?
    Thanks for your help.
    Stephan

    See Top 25 Bugparade: # 4264750
    This is a SecurityManager - Problem and the java.io.File.
    eg.:
    System.setSecurityManager(new RMISecurityManager());
    File[] roots = File.listRoots();
    Then you will see the problem...
    I tried the following workaround:
    before you access disk. (or JFileChooser)
    SecurityManager sm = System.getSecurityManger();
    System.setSecurityManager(null);
    // disable the SecurityManger
    // this special disk access needs no SecurityManager..
    ... popup JFileChosser or make FileAccess..
    System.setSecurityManager(sm);
    // restore the old SecurityManger
    It's not the best solution but it works..
    hope this will help,
    Wolfgang
    EDI Organisation

  • Doubt in creation of a new object

    Hi All,
                 I have one doubt in creation of a new object.If a new object is to be created and it is not a subtype
    of any existing object, then what should we enter in the Program field for creating the object?
    I hope I am clear with my question.
    Thanks in Advance,
    Saket.

    Hi Saket,
    Following will be required for created a custom business object.
    1. Object Type - ZTEST (Internal Techincal Key)
    2. Object Name - ZTESTNAME (Technical Key Name)
    3. Name - TEST (Name of BO, it is used while selecting the object type)
    4. Description - (Short Description of BO)
    5. Program - ZTESTPROGRAM (ABAP program in which the methods of the object type are implemented)
    6. Application - A or B.. etc (Area to which your BO is related)
    Please remember that you can learn these basic things by giving F1 help on those fields and in HELP.SAP.COM.
    Regards,
    Gautham Paspala

  • Doubt in sender mail adapter

    Hi Everyone,
    Can we read and validate the attachment of the mail.If so how to do it.
    Thanks in advance,
    Sakthi

    Hi Sakthi,
       Please refere the below links:
      http://help.sap.com/saphelp_nw2004s/helpdata/en/ad/bf93409c663228e10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/0d/52b240ac052817e10000000a1550b0/frameset.htm
    Let me know if you have any doubts regarding this.
    Thanks,
    sekhar.

  • Can not sort the files in JFileChooser if the files are from remote machine

    Hi All,
    Let me set the context of the question.
    I have extended the JFileChooser to support the listing/view of files.dirs etc of remote location through CORBA.To achieve that i have customized
    my FileSystemView to support it. In general ,the current JFileChooser sorts the file when we have details view .My question is related to this.The default
    JFileChooser has the support for sorting but when i customized the FileSystemView,the sorting functionality is no more exist.I tried with TableRowSorter as well but
    the sorting can be achieved in View only,the model still remains same as initial.
    Any pointer towards this will be highly appreciated.
    Thanks
    Praveen

    Can anyone help me out to solve this problem or any suggestion regarding this ?
    Regards
    Praveen

  • PI' RFC  Connection pool  doubt.

    Hi PI exports:
    i have a doubt about  pi' RFC  Connection pool ,pi RFC receive channel can set the conn pool size ,but when start the rfc receiver channel ,is there always only one Connection  pool ,or there is only one Connection  pool  instance?
      thinks
    Edited by: kevin liang on Oct 19, 2009 6:45 AM

    Hi,
      Connection poolins size means how many number of connection you want to make open to send data to ECC, We can define maximum number of connection in Receiver RFC Adapter,Go to additional parameters section and define Max Number of connection give the number there,thats it.Internally it works as Connection poolin mechanism.
    Regards,
    Raj

  • Small Doubt Regarding SY-MANDT

    Hi All,
         SELECT changenr FROM cdhdr CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF TABLE it_cdhdr
                                             WHERE mandant = syst-mandt
                                             AND   objectclas = 'MATERIAL'
                                             AND   objectid   = wa_matl-matnr
                                             AND   tcode      = 'MM02'.
         I have written the select stament as shown above.
         In this i have a doubt like adding a field sy-mandt  in the where condition will increase the Efficiency of program or not.
    regards,
    raghu.

    Hi..
    No doubt the efficency would be affected but from business point of view there will many  things that need to be checked as in:
    If you are viewing data from CDHDR and CDPOS which is client specific then you are not viewing complete data.
    These tables give us and document changes made to a particular object in SAP but if anything is cross client like company code(lets assume) then changes to it wont be visible in all the clients..
    so there can be some key information you can miss out while working on some of the objects.
    else in this case its good to make query cross client.
    regards
    vishal

  • Doubts with control break statements on internal table loops (AT/ENDAT)

    Hi, i've had a couple of doubts for a long while which I hope someone can clarify today:
    1) I know how to use the AT statements, however, i'm not sure I get correctly what this part of help regarding this commands means:
    <i>"The control level structure with internal tables is static. It corresponds exactly to the sequence of columns in the internal table (from left to right). In this context, the criteria according to which you sort the internal table are unimportant."</i>
    I've always sorted the internal table before the control break and it works that way. For example:
    SORT ITAB BY EBELN EBELP.
    LOOP AT ITAB.
      AT NEW EBELN.
    *   Code for the order header
      ENDAT.
    ENDLOOP.
    If I <b>don't</b> sort the internal table, it doesn't work! (i get dupplicated processing). In the example, if i have more than one register with the same EBELN and they're not consecutive, the header gets processed twice. I really don't get that part of the help text.
    2) I know this: <i>"At the start of a new control level (i.e. immediately after AT), the following occurs in the output area of the current LOOP statement:
    All character type fields (on the right) are filled with "*" after the current control level key.
    All other fields (on the right) are set to their initial values after the current control level key."</i>
    My doubt is: WHY is that this way? Because sometimes (most times) I need those fields INSIDE the statement! So when that happened i've solved it in one of three ways:
    LOOP AT ITAB INTO WA_ITAB.
      WA_ITAB_AUX = WA_ITAB.
      AT NEW FIELD.
        WA_ITAB = WA_ITAB_AUX.
    *   ...Rest of the code for the first register
      ENDAT.
    ENDLOOP.
    LOOP AT ITAB INTO WA_ITAB.
      AT NEW FIELD.
        READ TABLE ITAB INDEX SY-TABIX INTO WA_ITAB.
    *   ...Rest of the code for the first register
      ENDAT.
    ENDLOOP.
    * (Without AT)
    LOOP AT ITAB INTO WA_ITAB.
      IF WA_ITAB-FIELD <> FIELD_AUX.
        FIELD_AUX = WA_ITAB_FIELD.
    *   ...Rest of the code for the first register
      ENDIF.
    ENDLOOP.
    Is there any problem with this way of coding? Can be done better?
    Thank you very much in advance.

    Hi..,
    1)
    See if u sort the table on a field on which u r using AT ENDAT .. then all the records which are having the same value for that field will form a group or those reocrds will be at one place.. so when u sort the table for all the records  AT ENDAT  will get executed onli once..
    If u dont sort this table on this field then all these records will be at different places and in between there may be records with different value for this field.. so this AT ENDAT will get executed for each record !!
    2)
    No u cannot use the Right hand fields of the field in the table .. Because these AT events work as Group based operations... So till that field on which AT ENDAT is working it breaks that record into two groups.. One is the left hand fields including that field.. and right hand fields as another group.. and makes the right hand group as stars ****.  Thats y u can observe that even any one field in the left hand group changes the AT ENDAT will get executed  !!!!
    Hope u understood !!!
    regards,
    sai ramesh

  • LOOP DOUBT INSIDE  PACKAGE

    CREATE PACKAGE EMP_PKG AS
    CURSOR EMP_CUR IS
    SELECT EMPNO,DEPTNO,SAL,HIREDATE
    FROM EMP
    WHERE DEPTNO=30;
    PROCEDURE P_EMP;
    PROCEDURE P_GET_SAL(V_EMPNO NUMBER);
    PROCEDURE P_GET_LOC(V_EMPNO NUMBER);
    Now inside my Package Body
    INSIDE THE MAINPROCEDURE P_EMP
    I WILL BE CALLING THE BELOW TWO PROCEDURES
    PROCEDURE P_EMP
    BEGIN
    FOR I IN EMP_CUR LOOP
    P_GET_SAL(I.EMPNO);-- DO I NEED TO LOOP AGAIN IN P_GET_SAL PROC?
    P_GET_LOC(I.DEPTNO);
    END LOOP;
    END;
    NOW WHAT IAM DOING IS
    in my P_GET_SAL Procedure is
    PROCEDURE P_GET_SAL(V_EMPNO NUMBER)
    V_SAL EMP.SAL%TYPE;
    BEGIN
    FOR I IN EMP_CUR LOOP
    SELECT SAL INTO V_SAL FROM EMP
    WHERE EMPNO=I.EMPNO --DOUBT HERE
    END;
    I WANT TO KNOW WHETHER I NEED TO LOOP AGAIN
    HERE OR INSTEAD OF THAT
    PROCEDURE P_GET_SAL(V_EMPNO NUMBER)
    V_SAL EMP.SAL%TYPE;
    BEGIN
    SELECT SAL INTO V_SAL FROM EMP
    WHERE EMPNO =V_EMPNO;
    END;
    SINCE iam calling V_EMPNO WITH CURSOR FROM MY
    MAINPROCEDURE ..
    WILL THE PROCEDURE USES THE CURSOR VALUES
    AND LOOP ITSELF FOR EVERY EMPLOYEE TO
    GET THE SALALRY ?
    PLEASE LET ME KNOW SINCE MY PACKAGE IS MORE THAN 3000
    LINES I cant proceed unless its confirmed i can
    do so ..

    Hi all,
    Thanks for Looking into my Problem
    I Got answer by MySelf ..i dont need to loop again my sub procedures
    if i try to do that iam getting the error
    ERROR at line 1:
    ORA-06511: PL/SQL: cursor already open
    Thank you all once again ..

  • Doubt on Rows and Coloums in BEx Query Designer.

    Hello, Experts.
    I have a Doubt in BEx Query Designer.
    In the Rows I have a Fiscal year Period,  if the user enters the Fiscal year period for e.g. : 001/2006  .  
    in the columns i have  forecast for the Fiscal year period which user entered ( 001/2006 ),   and we have another column pervious ( Prior )fiscal year period ( 001/2005 ). 
    My Questions is ,  as we are Restricting with 001/2006 will the query retrieve the values of 2005 or not?
    Thanks in Advance .
    Sharp

    yes i am  Doing Offest.
    I moved this Fiscal year Period to Free char,   and i Restricted with Pervious Fical Year period and Fical year period .  it worked.  but
    when i kept this in Rows and deleted Previous Fiscal Year period .  it is displaying blanks.   in prior years forecast.
    is it because i am Ristricting it to only fical year period  which user entered
             Colums-->  Forcast ( User Entered year )          Prior year
    Rows
    Fiscal year period
      Fiscal year period( user enterd )
    Thanks

  • JFileChooser (again!) slow in JRE 1.6.14 on some machines, not others

    I am running ImageJ (from the NIH) on several of our machines and on some machines JFileChooser is lightning fast, while others exhibit the same slowness spoken of in another JFileChooser thread that is now in a locked state. We open large image files (tif, png) located on our SAN and from the network traffic I see in Windows Task Manager while opening a folder containing the images I would guess that JFileChooser is actually opening the files (intentionally or not), not just obtaining a folder listing. It's similar to the same issue of opening a large folder of images with the view set to thumbnails - it takes about the same amount of time. I have tried the suggestions in that thread to no avail - the environment the machines are running is:
    Windows XP SP3
    Java JRE 1.6.0_14
    Can anyone comment on what JFileChooser is doing and how I can get it to stop this? Is it a Windows environment setting so that the native API calls made by JFileChooser will behave differently? Thoughts?
    Thanks,
    Tom

    I can't be absolutely sure, but we have several seemingly identical machines used for the purpose of reading medical images and several of them appear to work correctly (very fast loading and population of the folder's contents) and others don't. I have been using eclipse to enhance the software tool we're using (ImageJ) and using the debugger I can see that when the JFileChooser object is being instantiated and populated with entries a tremendous amount of network traffic occurs. This network traffic is equivalent to the amount I see when the same folder is opened in My Computer using a thumbnails view of the folder contents. Apparently, the network is delivering approximately 300-400 MB of images. As far as configuration of the Windows machines is concerned I haven't found a significant difference yet, though I admit I am not a Windows desktop admin and may not know of some configuration item that could be responsible. I assume (though could be mistaken) that both My Computer and JFileChooser are ultimately using similar API calls to get the folder content entries?

  • Doubt regarding facebook integration for windows phone 8.1 silverlight app?

    Hi,
    I am developing a windows phone 8.1 silverlight application . For my application I integrated the facebook login. For this facebook integration I used the login with facebook app method.
    My doubt is after getting the app id from the dev center , I updated the appid at developers.facebook.com , wmmanifest.xml (In extensions protocol (msft-appid without dashes)) . Or do I need to change the product id in the place holder also , I tried to
    change the productid also but I am getting error like some signature is wrong try with different signature. I am confused how to do it .
    Any help,
    Thanks...
    Suresh.M

    Hi Suresh,
    According to your description, I assume you want to complete facebook configuration in windows phone silverlight app. Please refer to the following link to see how.
    http://facebooksdk.net/docs/phone/config/.
    You can find code sample from
    https://github.com/facebook-csharp-sdk/facebook-winclient-sdk/tree/master/Samples.
    Facebook API is third-party library and it is our of our support range. You can post questions on here.
    https://github.com/facebook-csharp-sdk/facebook-winclient-sdk/issues.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

Maybe you are looking for

  • How to bind the value of slider from C# code in windows phone 8.1..?

    Hi, I want to bind a custom seek bar to the position of media element. I think from XAML we can achieve it by       Value="{Binding ElementName=mediaElement, Path=Position, Mode=TwoWay, Converter={StaticResource FormatConverter}}" where FormatConvert

  • Itunes refuses to sync my iphone

    itunes refuses to sync my iphone 4s with a message "The iphone "Myname" iphone cannot be synced. An unknown error occurred (-50 )". Can anyone explain this message, please?

  • Do Leopard && Aiport support WPA ?

    Hi All , I would like to know whether WPA feature (Wi-Fi Protected Access ) has been supported by both wireless network adaptor (Airport) in the MacBook Black and Leopard (OS version - 10.5.2). I have a NETGEAR WPN824 router and would like enable WPA

  • Personalization in BEx: transport activation to production ?

    Hi, on our development system (SAP BW 3.1) we have activated the "personalization in bex" via "BW Customizing - Implementation Guide - Business Information Warehouse - Reporting-relevant Settings - General Reporting Settings Activate Personalization

  • My iPhone5s couldn't activate after i'd erased all my settings

    I got my iPhone5s 2months ago. This was happened last 2wks, i've found out that my phone wasn't able to received incoming text and call and i look for my Network which is (AT&T) it says "Searching.." so i've told this issue to my sister and we called