Results 1 to 6 of 6
  1. #1
    Bubba_OH's Avatar
    Bubba_OH is offline Member
    Join Date
    Oct 2008
    Location
    SW OH
    Posts
    12
    Rep Power
    0

    Default Default Swing Images

    I have downloaded the default images in jlfgr-1_0.jar, and put this jar file at:
    c:\Java

    From the control panel, I have set CLASSPATH to be:
    .;C:\Java\jlfgr-1_0.jar

    I am unable to get the images to appear in the simple app that I copied (I can't put it here because I am a newbie). They have good examples, but no real help.

    What am I missing? :confused:
    Using Windows Vista, Eclipse, NetBeans, jdk1.6.0_07

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Many possiblities for problems. So hard to know where to start.
    What is in the .jar file that you mentioned?
    Where is the program code? What command do you issue to start the program? Do you get any error messages?
    What is in the jar file's manifest file?
    Did the program ever work?
    Are the paths to the images in the jar file correct?
    How does the program access the images?
    I'll will let you try to answer the above and we'll go on from there.

  3. #3
    Bubba_OH's Avatar
    Bubba_OH is offline Member
    Join Date
    Oct 2008
    Location
    SW OH
    Posts
    12
    Rep Power
    0

    Default

    The .jar file ca,e from Sun and contains a folder called "toolbarButtonGraphics".
    In that folder are multiple sub-folders, including one called "general". In general, are a bunch of 16x16 gif and corresponding 24x24 gifs. They have names like Copy16.gif, Copy24.gif, Cut16.gif, Cut24.gif, etc.
    I use Eclipse and my code is in the workspace. This specific code is in:
    c:\Users\BuBBa\workspace\SwingRolloverComponent\sr c\RolloverComponent.java.
    I run the code from Eclipse using the run button.
    I get no errors, but no images. I have tried this with multiple examples, and they all work except I do not get the images in the .jar file.
    The code I copied is at:
    www roseindia net/ java/ example/ java/ swing/ RolloverComponent.shtml
    (pardon the spaces in the link - I can't post links on this site yet - I'm not trying to cheap, but rather give the EXACT code I copied).
    That site has some nice, simple examples and everything I have tried has worked very well except getting the images from the .jar file.

    I guess the first question is: Java should be able to extract these images, right?

    Thanks.
    Using Windows Vista, Eclipse, NetBeans, jdk1.6.0_07

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    I've seen the roseindia site. They have poor examples with extremely poor coding style. I advise you to stay away from there.

    If you're looking for a tutorial, why not use Sun's own one?
    The Java™ Tutorials

    AFAIK CLASSPATH is for loading classes, not resources. I suggest you extract the images you need to a folder in your project hierarchy and load them using getResource.

    db

  5. #5
    Bubba_OH's Avatar
    Bubba_OH is offline Member
    Join Date
    Oct 2008
    Location
    SW OH
    Posts
    12
    Rep Power
    0

    Default

    Thanks for the advice. I will check out your suggested link.
    Using Windows Vista, Eclipse, NetBeans, jdk1.6.0_07

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    Yes, java can read images from jar files.
    How does the program access the images?
    What is the source code used to read the images?
    What path is used?
    What are the paths to the images in the jar file? Use winzip to look inside the jar file.
    The paths must match.

    To get resources from a jar file you must use a getResource method. The code you are using probably tries to read from a local disk. There are code examples on the forum on how to use getResource. Use Search.
    Last edited by Norm; 10-10-2008 at 03:03 PM.

Similar Threads

  1. want default value in ComboBox from DB!!
    By Java.child in forum AWT / Swing
    Replies: 2
    Last Post: 10-04-2008, 12:25 AM
  2. want default value in ComboBox !!
    By Java.child in forum SWT / JFace
    Replies: 0
    Last Post: 09-29-2008, 09:57 PM
  3. Printing default Swing values
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-12-2008, 11:09 AM
  4. Swing - Changing component default font
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-11-2008, 10:52 PM
  5. Default Button
    By hiranya in forum AWT / Swing
    Replies: 2
    Last Post: 11-01-2007, 06:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •