Applying Images from Resource Directory in JBuilder 2006

Hi!
I am having a nightmare on that.
I've been trying to create a Choice List with Images, however, JBuilder never finds the images' location.
I've tried creating a resource directory everywhere in my project folder, however, I coulnd't resolve the issue.
The code where I get the error is as follows:         try{
          // create and array of image items
          Image images[] = {Image.createImage("/res/star.png"),
                            Image.createImage("/res/star.png"),
                            Image.createImage("/res/star.png")};
          // Create array of Strings relating to images
          String selections[] = {"Next", "Previous", "New"};
          // create List using arrays, add commands, Listen for events
          lsChoice = new List("Your Option:", List.IMPLICIT, selections, images);
          lsChoice.addCommand(cmExit);
          lsChoice.addCommand(cmAdd);
          lsChoice.setCommandListener(this);
        catch (java.io.IOException e){
          System.out.println("Unable to Find or Read .png file");
          System.out.println("Check if the path to .png file is correct!");
        }Like I said, it kept throwing IOException error regardless of where I've placed the resource directory in my project.
Could anyone help me on that pls? I've wasted so much time on it, and I couldn't go any further with it...
Thank you a lot!
Message was edited by:
Yav

Instead of
Image.createImage("/res/star.png")
use
Image.createImage("/star.png")

Similar Messages

  • Firefox won't display an image from one directory, but will from another. IE displays both.

    I have some very simple logo jpgs I want to add to www.foautah.org. I have been having a problem where IE will show the jpgs, but Firefox won't. I have narrowed it down to a very simple test and found that in a little html test page: test.foautah.org/test.html Firefox will load two images from one directory (graphics), but not from another (sponsors). The images are identical copies. IE shows both from both directories.
    NEVER MIND. After wasting hours, it finally dawned on me that Adblock might be doing something. Turns out it hides anything with "sponsors" in it. Time to rename my directory. Argh!!!

    hello, yes, you'd have to uninstall flash from the windows control panel in windows7 (just diabling it in firefox won't work in this case). alternatively you could run the uninstaller-tool that adobe provides on its website: http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-windows.html

  • How to call image from OA_MEDIA directory

    Hi all
    i need to call a image from OA_MEDIA directory in my template ,would please somebody help me ,would u please share the syntax for this requirement ,
    Thanks
    Pratap

    Thanks Kavipriya for the prompt reply ,
    actually i also got this syntex in dev guide but not able to understand how to use this in template ,can i call a image (for testing purpose only ) from my c drive also ,if yes would please give me sample syntax if my image is residing in c:\assignment directory ,i will be thankful to you .
    thanks
    Pratap

  • InDesign CC will only let me place images from one directory

    I am a print designer and recently switched from a PC to a MacBook Pro. I'm using InDesign CC and it will only let me place images from one directory. If I try and choose another directory, the Finder window just disappears.

    Are you on Mac 10.9? There is an issue on mac 10.9 w.r.t finder window when try to open/pace file in "cover flow view" mode. The finder window dissapears then.
    Workaround: Choose Icon View, List View, or Column View

  • Displaying image within a directory

    Hi everyone, i am doing a project on displaying image within a directory. But i am not sure how to do it. Is it possible to display all the images from a certain directory folder?? Thank in advance..

    Thank for reply. I know how to call a image from a folder and display it on the jsp page But I am trying to display all the images in that folder and display all of them on the jsp page like a online photo album. But i do not know how to do that. Any help or guide on displaying images from a directory. Thank!!

  • Which is better? Extracting images from directories or from database?

    Good day,
    I would like to start a discussion on extracting image (binary data) from a relational database. Although some might say that extracting image from directories is a better approach, I m still sceptic on that implementation.
    My argument towards this is based on the reasonings below:
    1. Easier maintainence. - System Administrator can do backup from one place which is the database.
    2. High level of security - can anyone tell me how easy it is to hack into a database server?
    3. image is not dependent on file structure - no more worries about broken links because some one might mistakenly change the directory structure. If there needs to be a change, it will be handle efficiently by the database server.
    The intention of my question is to find out :
    1. Why is taking image from a directory folder which resides on the web server is better than using the same approach from the database?
    2. How is this approach (taking image from directory) scalable if there is thousands of images and text that needs to be served?
    If anybody would be kind enough to reply, I would be most grateful.
    Thank You.
    Regards
    hatta

    Databases are typically more oriented towards text and number content than binary content, I believe. If you carry images in the database you will need to run them through your code and through your java server before they are displayed. If they are held in a directory they will be called from hrefs in the produced page, which means that they are served by your static server. This is quicker because no processing of the image is required. It also means the Database has to handle massively less data. Depending on the database this should be far quicker to query.
    It is worth noting that it is also quite difficult to actually change mime-types on a page to display a picture in the midst of HTML- the number of enquiries on these pages about this topic should be enough to illustrate this.
    If you give over controls of all the image file handling to your java system (which I do when I write sites like the one you describe) then the actual program knows where to put the images and automatically adds them to the database. The system administrator never needs to touch them. If they want a backup they save the database and the website directory. The second of those should be a standard administrative task anyway, so there is not a huge difference there. The danger of someone accidentally changing the directory structure is no greater than the danger of someone accidentally dropping a database table- it can be minimised by making sure your administrators are competent. Directory structures can be changed back, dropped tables are gone.
    The security claim is slightly negated because you still have to run a webserver. Every program you run on your server is vulnerable to attack but if you are serving web pages you will have a server program that is faster than a database for image handling. You are far more at risk from running FTP or Telnet on your server or (worst of all) trying to maintain IIS.
    The images in directory structure is more scalable because very large databases are more likely to become unstable and carrying a 50k image in every image field rather than 2 bytes of text will make the database roughly 25000 times larger. I have already mentioned the difference in serving methods which stands in favour of recycling images. A static site will be faster than a dynamic site of equivalent size, so where you can, take advantage of that.

  • Apply image to layers below target, or merge to new layer

    I'd like an option to apply image from source: "layers below the target layer", instead of the current options of merged or choosing a layer.
    or
    possibly a more flexible and faster method may be to choose a selection of contiguous layers and add a "merge to new layer" menu choice. This would merge the selected layers and flatten to a new layer above the selected layers.
    This would be convenient for interim builds of layers and retaining layered work.
    ......  yes there are many ways to do this currently, this is a feature request.

    Hi Chris
    Sorry for the delay a bunch of stuff landed on my desk.
    >I don’t want to annoy you, but could you be more specific?
    no worries, you're a very helpful person around here. There's nothing really specific, a fun new features areas should be exciting, and there's little benefit to anyone posting ( except for egos ) so I think I'll hang around the other areas that are focused on fixing problems.
    regards
    j

  • Reading only Image files from a directory

    i am wanting to be able to read a directory but only obtain the Image files (ie, gif, jpeg, tiff, png etc) and ignore all other type of files.
    i have made a custom ImageFIlter class which extends FileFilter which works for adding a photo singly, as only image files are shown in the JFileChooser. however i am wanting to add a folder of photos at once.
    here is the code so far:
    File dir;
                        JFileChooser fc = new JFileChooser();
                        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                        //Handle open button action.
                        int returnVal = fc.showOpenDialog(MainAppGUI.this);
                        if (returnVal == JFileChooser.APPROVE_OPTION) {
                             dir = fc.getSelectedFile();
                             if (dir.isDirectory()) {
                                  File[] files = dir.listFiles(new FileFilter());
                                  for (int i = 0; i < files.length; i++) {
                                       if (files.isFile()) {
                                            try {
                                                 Photo PhotoAdded = workingCollection.addManyPhotos(files[i], canvas.getChangedMaxDim());
                                                 //need to also add it to the relevant vectors, ie
                                                 //for mouse over operations, or photos added after
                                                 //save.
                                                 if(!workingCollection.isDuplicate()){
                                                      photosToCheck.add(photoAdded);
                                                      canvas.addToGrid(photoAdded);
                                                      photosAddedAfterLoad.add(photoAdded);
                                                      canvas.repaint();
                                                 else{
                                                      //do nothing as it is already in the vectors.
                                            } catch (Exception er) {
                                                 // Do nothing. Bad mp3, don't add.
                                       // recurse through directories
                                       else {
                             } else {
                                  try {
                                       throw new IOException(
                                                 "Error loading files from a directory: "
                                                           + dir.getAbsolutePath() + " is not a "
                                                           + "directory");
                                  } catch (IOException e1) {
                                       // TODO Auto-generated catch block
                                       e1.printStackTrace();
    any ideas?

    it shouldnt be new FileFilter() there, it should be new ImageFilter() but it gives a compilation error saying i cannot apply that parameter to the listFiles() method in the File class

  • Reading only Image Files from a Directory and ignoring the rest

    i am wanting to be able to read a directory but only obtain the Image files (ie, gif, jpeg, tiff, png etc) and ignore all other type of files.
    i have made a custom ImageFIlter class which extends FileFilter which works for adding a photo singly, as only image files are shown in the JFileChooser. however i am wanting to add a folder of photos at once.
    here is the code so far:
    File dir;
                        JFileChooser fc = new JFileChooser();
                        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                        //Handle open button action.
                        int returnVal = fc.showOpenDialog(MainAppGUI.this);
                        if (returnVal == JFileChooser.APPROVE_OPTION) {
                             dir = fc.getSelectedFile();
                             if (dir.isDirectory()) {
                                  File[] files = dir.listFiles(new ImageFilter());
                                  for (int i = 0; i < files.length; i++) {
                                       if (files.isFile()) {
                                            try {
                                                 Photo PhotoAdded = workingCollection.addManyPhotos(files[i], canvas.getChangedMaxDim());
                                                 //need to also add it to the relevant vectors, ie
                                                 //for mouse over operations, or photos added after
                                                 //save.
                                                 if(!workingCollection.isDuplicate()){
                                                      photosToCheck.add(photoAdded);
                                                      canvas.addToGrid(photoAdded);
                                                      photosAddedAfterLoad.add(photoAdded);
                                                      canvas.repaint();
                                                 else{
                                                      //do nothing as it is already in the vectors.
                                            } catch (Exception er) {
                                                 // Do nothing. Bad mp3, don't add.
                                       // recurse through directories
                                       else {
                             } else {
                                  try {
                                       throw new IOException(
                                                 "Error loading files from a directory: "
                                                           + dir.getAbsolutePath() + " is not a "
                                                           + "directory");
                                  } catch (IOException e1) {
                                       // TODO Auto-generated catch block
                                       e1.printStackTrace();
    any ideas?

    I'm confused.
    You already ARE using a FileFilter to only pick up image files. Whats the problem?
    If you need to recurse directories you need to change your code only a little.
    Write your method
    JFileChooser fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    //Handle open button action.
    int returnVal = fc.showOpenDialog(MainAppGUI.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      dir = fc.getSelectedFile();
    if (dir.isDirectory()) {
      scanDirectory(dir);
    else{
      // not a directory
    public void scanDirectoryForPhotos(File directory){
      // taking your code
    if (dir.isDirectory()) {
      File[] files = dir.listFiles(new ImageFilter());
      for (int i = 0; i < files.length; i++) {
        if (files.isFile()) {
    // details deleted
    // recurse through directories
    else {
    scanDirectory(files[i]);
    Your exception handling is a little strange. You throw an exception only to catch it immediately to print a stack trace? Not exactly the most common handling I've seen. You should probably just throw the exception and let the next level down handle it.
    Cheers,
    evnafets

  • Importing images from all subfolders within a directory and only within that directory

    Hi All
    I volunteered to oragnise my grandmas photo collection after I started using lightrooom.
    My experience of lightroom started off great but has gone down hill since then. This should be very easy to do. Contanstant propblems now being able to read LR4 catalogs and upgrade them to LR5 format
    My most recent problem is I have copied the entire contents of my grandmas computer to a portable hard driv
    Drive I:\ directory I:\grandma.
    I now want to create a new catalog in lightroom so I can import all her photos (scattered all over the computer in various files, she had no structure) into one single folder, so everything is organised.
    The problem is (I have tried lightroom 4 and 5 each with a different problem):
    In lightroom 5 I open a new catalog, open the import dialog and point it to the directory I:\grandma, then I click the show all subfolders (it only recognises 150 image but there are at least a few thousand) I think it is only recognising the immediate folder even though I have the ALL photos option selected, and the copy all photos and import from subfolders options selected.) At the very least it is not recognising all the subfolders, in some cases there are about seven levels.
    What is the maximum number of images you can import in one go? And how many nested subfolders can you have?
    In lightroom 4 I open a new catalog and open the import dialog and point it to I:\grandma. However this time the import dialog box returns photos which I know are not in the directory I:\ grandmas. It is displaying a lot of my photos in the import dialog box (even though I have clearly selected the I:\grandma directory. when I use show in explorer I can see it is showing images from my C drive that it wants to import.
    Why is it doing this when I have clearly selected I only want to import my grandmas photos into the catalog from the directory I:\grandma?
    I have also followed Pete Green's directions here to 1. optimise the catalog ( I did it however not sure of the point when it is a new catalog with no images in it) and 2. remove xmp files of which there are none (see point 1.) http://forums.adobe.com/thread/1231573
    Please help.

    UPDATE--> Manually adding folders (drag from explorer and drop on music libray) appears to be functioning as a work around. I have been testing individual folders and so far so good.
    While this may be a workaround i have HUNDREDS of folders! =(

  • Load multiple images from directory?

    What is the best way to use CF to load multiple images from a
    server directory please? I have CF calling a stored procedure that
    returns an array of file names. I am using a Flex front end, and
    wonder if I should just pass the file name array to Flex and let it
    loop through and load each image into an array. Or is it possible
    from within my CFC to use the file name array to get CF to grab the
    images and then pass that image array back to Flex? If so, is there
    any advantage to either approach? TIA,
    Mic.

    You don't want to pass the binaries to Flex, you should just
    give Flex the image names and load them via HTTP.

  • Loading all images from Jar include the directory structure.

    Hi I would like to puts all my images in a Jar. is it going to improve the loading speed?
    I have a ImageLibary that load all the images to a hashtable and access each image by their path and filename.
    I only have to input the image root directory and it will load all the images including sub-directory. If I decide to put these directories in a JAR. is this still going to work? Do all the class files has to be in the same JAR?
    use getResourse()?
    My current ImageLibary is like this:
    public class ImagesLibary extends Component
    private Hashtable imagesBank;
    private Vector imagesName;
    private MediaTracker tracker;
    public ImagesLibary()
    imagesBank = new Hashtable();
    imagesName = new Vector();
    tracker= new MediaTracker(this);
    loadImageFile("./images");
    for(int i=0; i<imagesName.size(); i++)
    String key = (String)imagesName.get(i);
    Image image = getToolkit().getImage(key);
    tracker.addImage(image, 0);
    try
    tracker.waitForID(0);
    catch (InterruptedException e)
    System.err.println("Loading image: " + key + " fails. " + e);
    imagesBank.put(key,image);
    System.out.println("Loaded: " + key);
    System.out.println("Total of " + imagesBank.size() + " images.");
    private void loadImageFile(String dir)
    File imageDir = new File(dir);
    File temp[] = imageDir.listFiles();
    for(int i=0; i<temp.length;i++)
    if (temp.isDirectory())
    loadImageFile(temp[i].getPath());
    else
    imagesName.add(temp[i].getPath());

    is it going to improve the loading speed?depends :)
    is this still going to work?some ajustments are needed... but thats done quickly.
    Do all the class files has to be in the same JAR?no. but it's easier to handle.
    use getResourse()?yes. don't know if u have to. but i do it this way :)
    inside an application:
    URL keyboardImagePath;
    keyboardImagePath = (new Object()).getClass().getResource("/gfx/keyboard.gif");
    Image kb=getToolkit().getImage(keyboardImagePath);inside an applet:
    URL path = (new Object()).getClass().getResource( "/icons/right.gif" );
    // now make the icon getting the gif from the url
    ImageIcon = new ImageIcon( path );inside a hybrid:
    URL keyboardImagePath;
    keyboardImagePath = (new Object()).getClass().getResource("/gfx/keyboard.gif");
    System.out.println("<-(application)load:"+keyboardImagePath); //if u wanna c what happens
    if(keyboardImagePath==null)
         keyboardImagePath=selfRef.getClass().getResource("/gfx/keyboard.gif");
         System.out.println("<-(applet)load:"+keyboardImagePath); //if u wanna c what happens
    Image kb=getToolkit().getImage(keyboardImagePath);hope that was helpfull :)

  • Grabing images from camera & Apply OCR To that image

    Hi,
    I m developing a sample application on OCR. At last visit i m posting the same question.But no one can answer me.
    Here i Create a Vi for grabbing images from camera. The Images are grab & save to the desired folder.But the OCR is not working on that snap image.
    I m  modified some Sample NI VI's for capturing the images & for OCR.
    I m new for labview. I cant understand where is the problem in the VI.
    i also create a character set file for reading the characters using OCR Train
    so please help me to find the solution.
    Attachments:
    Character reading.vi ‏91 KB

    HI.
    Let me give some suggestions regarding your code, (See pictures), and attached an example that you could serve.
    Regards.
    Jonathan Cruz
    CHALLENGER
    K U D O S __ B I E N V E N I D O S
    Attachments:
    Camara OCR.vi ‏42 KB
    11.JPG ‏77 KB
    22.JPG ‏17 KB

  • Display image from external resource into interactive form

    Hi experts!
    How can I display an image from a external url, for example "http://www.adobe.com/imageshome/pdfgift_home.gif" ??
    I tried to do that:
    1. Insert a "Image field"
    2. Bind None
    3. Embed image data: unselected
    4. URL: $record.url
        In "url" it's a context's variable. It's type is string. I save in url: http://www.adobe.com/imageshome/pdfgift_home.gif
    4. Show: initialize
        Script: this.value.image.href = xfa.resolveNode(this.value.image.href).value;
        Language: JavaScript
        Run at: Client
    I can't save image into mimes' folder. It's a bussiness rule in my company.
    Thanks
    Gustavo Rodriguez

    have you tried directly linking it to the image this way? instead of passing through the context to make sure you can access the image?
    I just inserted an image on my form.
    Bind none
    Embed unchecked
    URL http://www.adobe.com/imageshome/pdfgift_home.gif
    Edited by: robert phelan on Jun 25, 2009 8:07 PM

  • Grabing images from & Apply OCR To that image

    Hi,
    I m developing a sample application on OCR. At last visit i m posting the same question.But no one can answer me.
    Here i Create a Vi for grabbing images from camera. The Images are grab & save to the desired folder.But the OCR is not working on that snap image.
    I m  modified some Sample NI VI's for capturing the images & for OCR.
    I m new for labview. I cant understand where is the problem in the VI.
    i also create a character set file for reading the characters using OCR Training.
    so please help me to find the solution.
    Attachments:
    Character reading.vi ‏91 KB

    HI.
    Let me give some suggestions regarding your code, (See pictures), and attached an example that you could serve.
    Regards.
    Jonathan Cruz
    CHALLENGER
    K U D O S __ B I E N V E N I D O S
    Attachments:
    Camara OCR.vi ‏42 KB
    11.JPG ‏77 KB
    22.JPG ‏17 KB

Maybe you are looking for

  • Apple Ram Upgrade

    So I have a MacBook Pro which uses the same type of Ram as the mac mini. It has 4 gigs but i am planning on upgrading it to 8. So i was wondering if someone at apple could upgrade a mac mini with my old ram and if so how much would it cost.

  • Bankdata in XL Reporter

    Hi@all where can i find the bankdatas in XL Reporter? i want to make a report to show, wich partners dont have any bankdatas. i know that it is part of the OCRD but i cant find it... please help... regards Bernhard

  • Messages as japanese appear as garbage on other end

    I have an AT&T IPhone 4 running IOS 5, my friend has Verizon IPhone 4 running IOS 4. When I send her a message in japanese it appears as garbage, when she sends me a message in japanese it comes over fine. Messaging in english works fine of course. W

  • Vist Basic & XFI, random loss of sound and World of Warcraft Hardware enabling iss

    Hello.. First off want to say that prior to reinstalling Vista last week, I had no had any issues with my XFI and Vista.. Since the re-install, while running World of Warcraft and Ventrillo, I get random loss of sound. And by that, specifically I mea

  • A little help. No more random detection of soundcard

    Pals, good evening. Reading this on arch wiki Set the default sound card First you will have to find out the card and device id that you want to set as the default by running aplay -l: $ aplay -l **** List of PLAYBACK Hardware Devices **** card 0: In