Adding files to jlist

hi,
i trying to add File objects to a JList can keep getting a nullpointer exception, here is the code:
private DefaultListModel listModel;
File file = new File("c:");
File[] files = file.listFiles();
addToListModel(files);
fileList = new JList(files);
public void addToListModel(File[] list) {
     System.out.println("lenght is " + list.length);
     System.out.println(list[0]);
     for(int i = 0; i < list.length; i++) {
          listModel.addElement(list);
i put a println in the method, it print 5 as the lenght and does output the first value in the array, but then throws the nullpointer excpetion, any ideas?
Thank you.

Are you sure you created listModel? I don't see
listModel = new DefaultListModel()in your sample? If you didn't it would be null.

Similar Messages

  • How to get latest added file from a folder using apple script

    Hi..
    I am trying to get a latest added file from a folder..and for this i have below script
    tell application "Finder"
        set latestFile to item 1 of (sort (get files of (path to downloads folder)) by creation date) as alias
        set fileName to latestFile's name
    end tell
    By using this i am not able to get latest file because for some files the creation date is some older date so is there any way to get latest file based on "Date Added" column of a folder.

    If you don't mind using GUI Scripting (you must enable access for assistive devices in the Accessibility System Preference pane), the following script should give you a reference to the last item added to any folder. Admittedly not the most elegant solution, but it works, at least under OS X 10.8.2.
    set theFolder to choose folder
    tell application "Finder"
        activate
        set theFolderWindow to container window of theFolder
        set alreadyOpen to exists theFolderWindow
        tell theFolderWindow
            open
            set theInitialView to current view
            set current view to icon view
        end tell
    end tell
    tell application "System Events" to tell process "Finder"
        -- Arrange by None:
        set theInitialArrangement to name of menu item 1 of menu 1 of menu item "Arrange By" of menu 1 of menu bar item "View" of menu bar 1 whose value of attribute "AXMenuItemMarkChar" is "✓"
        keystroke "0" using {control down, command down}
        -- Sort by Date Added:
        set theInitialSortingOrder to name of menu item 1 of menu 1 of menu item "Sort By" of menu 1 of menu bar item "View" of menu bar 1 whose value of attribute "AXMenuItemMarkChar" is "✓"
        keystroke "4" using {control down, option down, command down}
        -- Get the name of the last item:
        set theItemName to name of image 1 of UI element 1 of last scroll area of splitter group 1 of (window 1 whose subrole is "AXStandardWindow")
        -- Restore the initial settings:
        click menu item theInitialSortingOrder of menu 1 of menu item "Sort By" of menu 1 of menu bar item "View" of menu bar 1
        click menu item theInitialArrangement of menu 1 of menu item "Arrange By" of menu 1 of menu bar item "View" of menu bar 1
    end tell
    tell application "Finder"
        set current view of theFolderWindow to theInitialView -- restore the initial view
        if not alreadyOpen then close theFolderWindow
        set theLastItem to item theItemName of theFolder
    end tell
    theLastItem
    Message was edited by: Pierre L.

  • I am having problems adding files to my external hard drive. Can anyone help me?

    I can't add files to my external hard drive from my computer. I keep getting a message saying that the hard drive can't be modified. I've added files to it before, I'm not sure why it's not working now. I looked at the hard drive information and it says that it is set to read only. Does anyone know how to change that or what I should do? Thanks.

    Odd, it seems.  In the Finder "Get Info" display, you are seeing something like this?
    Click the "Details" triangle and then the little padlock, and you should be able to change the permissions.  Click the lock when you are done and close the Info window.

  • Applescript to change permissions of added files

    This is probably really simple but I need a folder action that will alter all added files permissions to R-R-R or alternatively to change the name of the group to "admin"
    The reason for this is because I have been experimenting with setting the global NSUmask so all files are saved to our server as RW-RW-R this is because Photoshop isn't taking any notice of the ACL's and so is making it difficult for different users to work on the same files. My idea is to have a raw image folder that has files saved RW-RW-R via the global unmask and then a folder action to change the permissions when the file gets moved into a Master Image folder

    Oh **** - figured how to do this myself, but realised to only affects files in the folder - not any in sub folders.
    Is there a different way to do this?

  • Adding file name in the sender Adaptor

    Hi ,
    I am facing some problem in adding file name .
    The scenario is like this :
    The file needs to be send from on system  and needs to be Archived . Once processed, the archived file should be prefixed with ARCH_ so that it is not picked up again .And the other thing given is the file name used will be of the format XXX_YYY_nnnnnnnnnn.DAT where nnnnnnnnnn is the date stamp .
    Please help it's urgent ......
    Thanks and regards
    Anita

    Hi,
    if you can have XML achvived files you can use
    standard
    processing mode: Archive
    with one swich you can set the timestamp mode
    yyyMMdd-hhMMss-SSS_.
    ref
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
    Regards,
    michal

  • [svn:osmf:] 14905: Adding file missing from previous commit.

    Revision: 14905
    Revision: 14905
    Author:   [email protected]
    Date:     2010-03-22 05:37:59 -0700 (Mon, 22 Mar 2010)
    Log Message:
    Adding file missing from previous commit.
    Added Paths:
        osmf/trunk/apps/samples/framework/OSMFPlayer/src/assets/fonts/
        osmf/trunk/apps/samples/framework/OSMFPlayer/src/assets/fonts/Standard0755.swf
        osmf/trunk/apps/samples/framework/OSMFPlayer/src/assets/fonts/readme.txt

    If you're confident that the DP contains the new file, try deleting the deployment and re-doing it (not the deployment type - just the deployment to your test collection).
    Gerry Hampson | Blog:
    www.gerryhampsoncm.blogspot.ie | LinkedIn:
    Gerry Hampson | Twitter:
    @gerryhampson

  • [svn:osmf:] 14904: Adding file missing from previous commit.

    Revision: 14904
    Revision: 14904
    Author:   [email protected]
    Date:     2010-03-22 05:32:49 -0700 (Mon, 22 Mar 2010)
    Log Message:
    Adding file missing from previous commit.
    Added Paths:
        osmf/trunk/libs/ChromeLibrary/org/osmf/chrome/hint/
        osmf/trunk/libs/ChromeLibrary/org/osmf/chrome/hint/Hint.as

    If you're confident that the DP contains the new file, try deleting the deployment and re-doing it (not the deployment type - just the deployment to your test collection).
    Gerry Hampson | Blog:
    www.gerryhampsoncm.blogspot.ie | LinkedIn:
    Gerry Hampson | Twitter:
    @gerryhampson

  • [svn:osmf:] 10540: Adding file missing from previous commit.

    Revision: 10540
    Author:   [email protected]
    Date:     2009-09-23 11:39:41 -0700 (Wed, 23 Sep 2009)
    Log Message:
    Adding file missing from previous commit.
    Added Paths:
        osmf/trunk/framework/MediaFrameworkFlexTest/org/openvideoplayer/gateways/TestHTMLGateway. as

    If you're confident that the DP contains the new file, try deleting the deployment and re-doing it (not the deployment type - just the deployment to your test collection).
    Gerry Hampson | Blog:
    www.gerryhampsoncm.blogspot.ie | LinkedIn:
    Gerry Hampson | Twitter:
    @gerryhampson

  • Itunes File Sharing: Adding files doesn't work

    Hi,
    i have a problem adding files via Itunes File Sharing in Apps. Here's my setup:
    Windows 7 64bit, german
    Itunes 11.1.5.5, x64, german
    Iphone 5s, 32GB, directly attached via USB
    several apps with file sharing support (OpenVPN, VLC, Good Reader...)
    Now, when i choose one of the apps and click "Add...", i get a file selection dialogue, select a file and click 'ok'... that's it.
    Nothing happens. The file is not added to the window.
    It's not added to the phone after a sync, so it doesn't seem to be a display  problem. But i don't get an error message at
    any point, so i'm quite flattered where to start looking for the problem.
    Steps so far:
    Reinstallation Itunes - no effect
    Reinstallation Drivers - no effect
    Starting with a new media library - no effect
    The only thing suspicious are some bonjour errors in the windows logs. But even with disabled bonjour service the problem persists.
    I've searched for this in the forums but didn't find a proper thread/answer for this.
    Anyone coming up with an idea? At least where to look for the problem? Is there a log file/command line parameter/deep inside special genius trigger to pull? I'm getting out of options here. :/
    Thanks a lot!
    Regards from germany,
    l0calhost

    Problem solved. Complete deinstallation of ITunes, computer restart, telephone restart and finally reinstallation of the app did the trick.
    But still, how would you debug a problem like this, when no error message comes up at any point?

  • Ok, so I accidently deleted my "recently Added" file!  How do I get it back?

    I accidentally deleted my recently added file from Itunes on my windows vista computer.  How do I get it back?

    It is simply a smart playlist.
    Make another

  • How can i add new files to my ipod from a different computer  without losing the added files on my ipod?

    how can i add new files to my ipod touch from a diferent computer without losing the added files already on my ipod?

    Email them? Use DropBox?  What type of files?

  • [svn:osmf:] 13186: Adding files missing from previous commit.

    Revision: 13186
    Revision: 13186
    Author:   [email protected]
    Date:     2009-12-23 05:26:07 -0800 (Wed, 23 Dec 2009)
    Log Message:
    Adding files missing from previous commit.
    Added Paths:
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityAuto_up.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityManual_disabled.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityManual_down.png
        osmf/trunk/libs/ChromeLibrary/assets/images/qualityManual_up.png

    I just checked my original file and it is 30fps...
    Also other clips from the same camera were correctly finalized, just this one clip "disappeared".
    Any ideas anyone?
    Thanks.

  • Adding file to Application deployment content after client deployment

    Hi,
    I have been testing deploying Visio 2013 via Application deployment and am having troubles with running an uninstall.
    After deploying the software successfully to my test client, I needed to make a change to the uninstall process & have added an new file that is now used during an uninstall.
    When running the uninstall on my test client, I can see the correct commandline being used; however it fails because the additional file has not been downloaded to the CCMCache folder on the client.
    I have run an 'update content' for the distribution type, cleared the clients cache & re-run the uninstall from Software Center. The client redownloads the source files, however it is still missing the new file that it needs.
    Checking on the distribution points, I can see the new file referenced in the SCCMContentLib folder.
    I tried removing previous revisions from the Application via the console & now when running the uninstall on the client it fails immediately without downloading the source files. Checking AppEnforce.log, it looks like the uninstall is referencing the
    old revision of the Application Deployment still (which didn't contain the additional file, and no longer exists in the revision history).
    Can anyone point me in the right direction to get this resolved?
    And also, what is the correct procedure for updating/adding files to an already deployed application?
    Thanks in advance!

    If you're confident that the DP contains the new file, try deleting the deployment and re-doing it (not the deployment type - just the deployment to your test collection).
    Gerry Hampson | Blog:
    www.gerryhampsoncm.blogspot.ie | LinkedIn:
    Gerry Hampson | Twitter:
    @gerryhampson

  • Lost "recently added" file

    Call me stupid but somehow the "recently added"
    file was deleted somehow from my itunes.I just cant figure out how to reinstall it??Any help is greatly appreciated. Thanks Jay

    Choose New Smart Playlist from the File menu and create a new smart playlist which lists items added in the last 2 weeks, excludes podcasts, and is live updated.
    (49947)

  • 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

Maybe you are looking for