Using image resources in a folder or another project's root

Hello,
I must confess that I find it annoying to place my pictures and icon resources in the same package to access them in the JavaFX application. I think this enforcement by JavaFX is an unreasonable one.
Consider that I use the same icon in several places in my application. It is the same resource that I have to put in several different places. Imaging the problems when trying to refactor or upgrading the application.
Is there a mechanism to access icons/picture resources in a folder at the root of the project or access these resources in a separate project. I would prefer the latter because in this way, I create a single project with all these resources and all other projects would access them from this project. I think this would allow updates, refactoring to be done much more easily.
If such a mechanism exists, please point me to it.
Than ks

Thanks for the correction.
Those last 3 examples donot use the classpath at all (although perhaps it does look in there).And so it is not; i.e. the last 3 examples did not use the classpath at all - and it did not look there either.
They will also load those resources from the current directory (or subfolders thereof).And so it is; i.e. when you don't specify a protocol, in the case of a stand alone app it looks up the resources relative to the current working directory. For webstart or applet it may use a codebase and grab the data from an originating server or something like that, but I didn't test that.
My mistake was thinking that if you didn't place the protocol in the image constructor it would default to looking stuff up relative to classpath of the calling class - which it does not do. If you did want to do such a lookup then the examples could instead be written as =>
new Image(getClass().getResourceAsStream("icons-390.jpg"));
new Image(getClass().getResourceAsStream("/icons-390.jpg"));
new Image(getClass().getResourceAsStream("../icons-390.jpg"));What I usually do is create a static getResource method on my application which returns a url to the resource, that way all of the resource lookup logic is localized in case I ever want to change how I find resources and where I place them.
static String getResource(String path) {
  return MyApplication.class.getResource(path).toExternalForm();
}

Similar Messages

  • How to Copy an Image File from a Folder to another Folder

    i face the problem of copying an image file from a folder to another folder by coding. i not really know which method to use so i need some reference about it. hope to get reply soon, thx :)

    Try this code. Make an object of this class and call
    copyTo method.
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class FileUtil
    extends File {
    public FileUtil(String pathname) throws
    NullPointerException {
    super(pathname);
    public void copyTo(File dest) throws Exception {
    File parent = dest.getParentFile();
    parent.mkdirs();
    FileInputStream in = new FileInputStream(this); //
    Open the source file
    FileOutputStream out = new FileOutputStream(dest); //
    Open the destination file
    byte[] buffer = new byte[4096]; // Create an input
    buffer
    int bytes_read;
    while ( (bytes_read = in.read(buffer)) != -1) { //
    Keep reading until the end
    out.write(buffer, 0, bytes_read);
    in.close(); // Close the file
    out.close(); // Close the file
    This is poor object-oriented design. Use derivation only when you have to override methods -- this is just
    a static utility method hiding here.

  • Copying clip/sequence into specific folder in another project?

    Hi,
    I have two suites working in different projects but im having to copy sequences from one to another....
    Is there a way to copy to a specific folder as they have a lot of rushes folders so need to close all those before doing this
    cheers

    Its actually sequences but yeah the media for it is on a shared network....its just the projects that are on seperate computer.
    We have a craft editor working and a logger so im just getting sequences off the logger to be copied into the main edit.
    Ideally want to be able to select a folder right click and paste in that folder...

  • How to get all image files from a folder to wwv_flow_files?

    Hi there!
    Is it possible in apex to show, in a report look-a-like, all image filenames from a folder in another machine (i enter in that machine by ip) and insert all files into wwv_flow_files?
    I want to see all files, then pick one and open a image...
    But it can't be by browse item... it has to show all filenames as a list...
    If it is possible, how can i do it?
    Thanks!
    Best regards,
    Luis Pires

    Hi,
    you can connect to the server using UTL_HTTP.
    Then for each files you copy the response into a BLOB to be able to show it or to store it in a table.
    A piece of code :
    begin
       -- initialize the BLOB.
       dbms_lob.createtemporary(l_blob, false);
       -- path to the file
       l_url := 'http://your_server/your_file.jpg';
       -- begin retrieving the target.
       l_req := utl_http.begin_request(l_url);
       -- identify ourselves (some sites serve special pages for particular browsers)
       utl_http.set_header(l_req, 'User-Agent', 'Mozilla/4.0');
       -- start receiving the response.
       l_resp := utl_http.get_response(l_req);
       -- copy the response into the BLOB.
       begin
          loop
             utl_http.read_raw(l_resp, l_raw, 32767);
             dbms_lob.writeappend (l_blob, utl_raw.length(l_raw), l_raw);
          end loop;
          -- stop when exception end_of_body is raised
       exception
          when utl_http.end_of_body then
             utl_http.end_response(l_resp);
       end;
    end;It's a minimal example, you may need authentication, check l_resp.status_code, etc...

  • Images I move from one folder into another are disappearing, at first it was occurring immediately if I did not copy and paste the images. Today however I found out that images I had been using for days just up and vanished from their new location.

    Images I move from one folder into another are disappearing, at first it was occurring immediately and only if I did not copy and paste the images. Today however I found out that images I had been using for days just up and vanished from their new location. A few of these images had copies in another folder that remained and the ones I couldn't find may or may not have ever had copies. I had backed up my system with time machine recently as well, so I went into the backup to retreive the lost images. When I searched and found the backup copies I got the error "the file alias cannot be opened because the original cannot be located". The crazy thing is that the images that remained on my computer did not give me the same error and opened like they should.
    In short images that I am creating, saving, and using are disapearing so epically that even time machine versions are affected when retrieval is attempted. Any suggestions as to what I could be doing wrong without realizing it? Or perhaps other people have had similar bugs that are software related and have a solution?

    Hi Kevin,
    I understand what you tried to do but it doesn't work that way. Swapping drive names will just mess things up.
    You should be able to reconnect the files though: in the Locate Referenced Files dialog make sure you click the Show Reconnect Options button — this will give you access to all the connected drives. Locate one of the files and hit Reconnect All. Should do the trick.
    Best

  • How can I move a folder to another catalog using LR 3

    I have imported a large amount of folder into cat#1, but now i have decided to create cat#2. I have tried to move the "folders" and not "catalog" using the following workflow:
    1- Opening cat #1, make selection of folder to be moved
    2- Go to file and select "Export as a cat".
    3- Opened cat #2, go to File and select "Import catalog"
    4- Importing window shows the entire list of folders I had imported previously (lots of them). They all are checked. I can see the path, but only see the location of the folders, but I can't read the name of the files. I am able to see the total number on each folder
    5- I have not even considering "synchronizing" the folder
    Oh another thing, when I go to cat#1 and locate the folder I "exported as a catalog". The folder still shows on cat#1, but I don't see it on cat#2. I guess because I didn't complete the task.
    I find it very tedious process trying to locate the file. And this is where I'm stuck
    I have searched so many ways to find a workflow that would make sense, but I tend to get nothing but responses about how to move a "catalog". I have been thinking doing the following:
    1- Remove the folder from cat#1
    2- Open cat#2 and import the same folder, but this again seems to redundant, boring and a lot of clicking. Any suggestions.

    Hm... Well, for everyone else the reply link is still on the website, and works fine soo....
    Tell me about it. I went to catalog #2 and I didn't see the exported
    catalog. Then I went back to catalog #1 and I still can see the entire
    folder that I had selected to Export. I double checked it the process and it
    seemed ok, but apparently there's something missing to complete the export
    You seem under the impression that exporting as a catalog removes the images from the first catalog.  This is not true.  As I said earlier, it makes a copy for you.  So of course, when you go back into catalog1, all of your images/collections/etc, are still there.  As they should be.
    So, you say you didn't see anything in your exported catalog?  Are  you sure you are opening the same catalog you just exported, or  have you opened a new blank one that you created, accidentally or not?  That would be my guess.
    I think you should start over, and very carefully take it one step at a time.
    Dj has suggested not using include negatives, and I can see where that might be useful.  However, if you do that, you will end up having images from two different catalogs in the same folder.  This will cause problems if you ever use the "sync folder" option, as it will attempt to load all images in that folder into your current catalog. Which means you could easilly end up with all your images in both catalogs.  Messy.   So to avoid this, use a new place instead.  You can also avoid having to do the "import to catalog" step by exporting the negatives at the same time.  Don't worry about exporting previews, though.
    First, find a new place (external disk, whatever) to create a new catalog in.  Do _not_ create the new catalog your self!  Make sure you are sending everything to a new place!
    Now, go into catalog1, and select all of the images you want to export.  They have to be selected, or nothing happens, and you'll just get a blank catalog.
    Now, export as catalog those images into the new location, and make sure you are copying the negatives too!  Double check before you hit go!
    Now, using LR, open that new catalog; you can either double click on the new one, or browse to open it.  Either way.  Verify that your images are in the new place and everything looks good.  You can see in the Folders tab on the left panel to make sure the images are in the right place in the new folder.
    At this point, you should have 2 and a half catalogs;  your new catalog with only the images you exported, and the old catalog, with all of your images.
    Now, you have a couple of choices.  But before you do either of them, make sure you backup your system, including all of the images in the original catalog.  If you've messed up making the new catalog (you should be able to tell!) then you want to make sure your original catalog can be restored.
    Open your original catalog again, and now remove all of the images you exported.  You will need to use the "remove from disk" option, as they will stay in the folders if you don't.  This would cause the above problem with "sync folder", and of course, use double the disk space.
    You can obviuosly see why I said to back everything up first;  if you messed up the export by not including the negatives, you could easilly delete your originals, and not have them _anywhere_, in which case  you would have to restore from back up and try again.
    You now have two separate catalogs.
    Remember, backup everything first, and good  luck!
    Cheers!

  • How use PHP to read image files from a folder and display them in Flex 3 tilelist.

    Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
    PHP :
    PHP Code:
    <?php
    //Open images directory
    $imglist = '';
    $dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "filename: " . $file . "\n";
    $dir->close();
    ?>
    FLEX 3 :
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.rpc.events.ResultEvent;
    public var image:Object;
    private function resultHandler(event:ResultEvent):void
    image = (event.result);
    ta1.text = String(event.result);
    private function faultHandler(event:FaultEvent):void
    ta1.text = "Fault Response from HTTPService call:\n ";
    ]]>
    </mx:Script>
    <mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
    <mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
    <mx:HTTPService id="pic" url="{phpPicture}" method="POST"
    result="{resultHandler(event)}" fault="{faultHandler(event)}"/>
    <mx:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
    <mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
    </mx:Application>
    Thanks. Need help as soon as possbile. URGENT.

    i have made some changes, in the php part too, and following is the resulting code( i tried it, and found that it works.):
    PHP Code:
    <?php
    echo '<?xml version="1.0" encoding="utf-8"?>';
    ?>
    <root>
    <images>
    <?php
    //Open images directory
    $dir = dir("images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "<image>" . $file . "</image>"; // i expect you to use the relative path in $dir, not C:\..........
    //$dir->close();
    ?>
    </images>
    </root>
    Flex Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="callPHP();">
    <mx:Script>
    <![CDATA[
    import mx.rpc.http.HTTPService;
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var arr:ArrayCollection = new ArrayCollection();
    private function callPHP():void
    var hs:HTTPService = new HTTPService();
    hs.url = 'Picture.php';
    hs.addEventListener( ResultEvent.RESULT, resultHandler );
    hs.addEventListener( FaultEvent.FAULT, faultHandler )
    hs.send();
    private function resultHandler( event:ResultEvent ):void
    arr = event.result.root.images.image as ArrayCollection;
    private function faultHandler( event:FaultEvent ):void
    Alert.show( "Fault Response from HTTPService call:\n " );
    ]]>
    </mx:Script>
    <mx:TileList id="tilelist"
    dataProvider="{arr}">
    <mx:itemRenderer>
    <mx:Component>
    <mx:Image source="images/{data}" />
    </mx:Component>
    </mx:itemRenderer>
    </mx:TileList>
    </mx:Application>

  • How do I use Automator to duplicate a folder with graphics on my desktop and erase their Resource forks?

    How do I use Automator to duplicate a folder with graphics on my desktop and erase their Resource forks?
    I do not use command line and tried to use ZapResourceForksAMAub_1.2 which I downloadedand instaled the Zap Resource Forks.action. Next I tried to use their sample copy-zap-rsrc.workflow in Snow Leopardon my Mac Pro. The 3 different steps are displayed in Automator but there is no place to put in which folder (on my deskto) to copy, and remove the resource forks from the graphic files.
    Can sombody please step me through this please please.
                                                                                          W.W.

    Unfortunately, Back to My Mac only works across computers using the same iCloud account.

  • My Photoshop CS 5 has some strange actions when I copy a portion of a photo using the clone stamp  to transfer to another part of the image. It carries the entire layer (not just the stamps selection) across the screen and I cannot place it where I need t

    My Photoshop CS 5 has some strange actions when I copy a portion of a photo using the clone stamp  to transfer to another part of the image. It carries the entire layer (not just the stamps selection) across the screen and I cannot place it where I need to. It appears as if I selected the entire layer on purpose (which I did not)
    The below items appeared when I opened Photoshop CS 5:
    “Photoshop has encountered a problem with the display driver and has temporarily disabled G & U enhancements. Check the video card malfunctions website for latest software. GPU enhancements can be enabled in the performance panel of preferences.”
    (I believe this started after the automatically updated Windows was applied. It was coincident with the before mentioned problem . . . but I don’t really know if it had anything to do with it. )

    For the Clone Stamp problem, check the Clone Source panel and Clipped is probably unchecked.
    If so, check Clipped and see if that makes a difference.
    (Window>Clone Source)
    As to the video card problem:
    Which version of windows are you using?
    What is the make and model of your graphics card?
    Do you know which update windows installed?

  • How to copy paste a office document from one folder to another using J2SE

    HI!
    How can i copy a document file(.rtf,.docx.pdf) from one folder to another folder by executing Java code?
    Help needed

    Hi! You can use my api com.gmail.ronilloang.util.FileUtil for copying files. You can download it at my homepage [RA (TM) i-Software|http://ang.ronillo.estares.googlepages.com/]

  • How to flip through multiple image files in a folder using Preview?

    On windows a default image viewing program similar to preview allows a user to press the arrow keys to flip through images within the same folder as the image file originally opened with a Preview-like application.
    How can a person filp through images in the same folder with a few keystrokes using Preview?
    thanks

    hmm...you mean there isn't a way to simply skim
    through images in a folder using an arrow or page-up
    key?? That's kind of disappointing...especially
    being forced to pre-select images...
    oceanbluesky,
    There's no reason you can't use Preview to do what you're trying to do. And there's no need to pre-select images.
    The trick is to open Preview first, and then choose Open from the File menu (or Command + O on the keyboard). When Preview's Open dialog window appears, navigate to the folder which contains your pictures. Highlight the entire folder and then press the Open button. Once the folder is open in Preview you should be able to use your arrow keys to flip through...
    Note: To avoid a storm of images from opening on your desktop, go to Preview > Preferences > Images and make sure that the "Open each image in its own window" radio button is not selected.
    Good luck!
    Andrew99
    iMac 1 GHz Flat Panel 15" PPC 768 MB RAM   Mac OS X (10.4.10)  

  • Basic Photoshop 101: I want to use an image with an outer glow in another Photoshop document. When I place the image, the outer glow has hard edges where the box of the image cut the glow off. Naturally, I want a soft feathered outer glow. How do I get th

    Basic Photoshop 101: I want to use an image with an outer glow in another Photoshop document. When I place the image, the outer glow has hard edges where the box of the image cut the glow off. Naturally, I want a soft feathered outer glow. How do I achieve that? Thank you.

    That should work out, maybe edit it to force updating in the new image.
    Could you please post a screenshot with the Layers Panel visible?

  • I'm trying to delete multiple pix in iPhoto that i stupidly made duplicates of without knowing, I've tried going into the applications folder and using image capture but i think I've missed a step , can anyone send the correct info / steps pls thanks

    I'm trying to delete multiple pix in iPhoto that i stupidly made duplicates of without knowing, I've tried going into the applications folder and using image capture but i think I've missed a step , can anyone send the correct info / steps pls thanks

    again image capture is not involved with deleting photos from iPhoto in any way ever
    the paid version of iPhoto Library Manager is very good for finding duplicates as is Duplicate Annihilator
    And I have no idea who told you this - or what it means - but re-read both of my opening statements
    I was told I could delete multpiles thru image capture by transferring my iPhoto library etc
    LN

  • When I have resized and saved an image in Photoshop (CS, version 8.0 for Mac) using image size, why is it so large when I open it in preview or another image viewer? Has it actually saved according to the size I specified?

    When I have resized and saved an image in Photoshop (CS, version 8.0 for Mac) using image size, why is it so large when I open it in preview or another image viewer? Has it actually saved according to the size I specified?

    You want to view the image at the Print Size, which represents the size that shows in the Image>Resize Dialog.
    View>Print Size
    Since screen resolution is almost always lower that the print resolution (somewhere between 72 and 96 usually), images will always look bigger on the screen, unless you view them at print size.
    (apple Retina displays have a much higher resolution than normal screens, closer to the average print size resolution)
    more info:
    Photoshop Help | Image size and resolution

  • To search only images in a particular folder of picture library using content search webpart.

    I have Images library where i am storing images in different folders.I need my content search webpart to search and display images in a particular folder in Images Library.For ex: i need to if my Picture Library Name is 'Images' a folder inside that is
    'Travel' which is having some images.I need my content search webpart to pick images from 'Travel' folder only.Any pointers to this will be helpful.

    Hi,
    According to your post, my understanding is that you want to search images in a particular folder via content search web part.
    When we use the search crawl the items in the images library, it crawls the items and folder with the following URL.
    For folder: http://sp13/PublishingImages/Folder1.
    For Items:
    http://sp13/PublishingImages/Forms/DispForm.aspx?ID=itemID
    It not crawls the items as the path
    http://sp13/PublishingImages/Folder1/Item, then we could not use this path to retrieve the items in the folder.
    As a workaround, we can create a custom field in the image library, such as a choice type field named
    Folders(it contains the folder names), when we create a image, we set the folder name in this field.
    Note: we should new a managed property manually to match the Crawled property.
    Then we can use this field to filter the items in a particular folder as below, it works like a charm in  my environment.
    path:"http://sp13/PublishingImages"   Folders=Folder1
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

Maybe you are looking for