Results 1 to 6 of 6
  1. #1
    Java.child is offline Member
    Join Date
    Sep 2008
    Posts
    32
    Rep Power
    0

    Default Already import the resources but images are missing

    Hi,
    I am very new to java and just joined this group.
    In my existing project every thing is running yesterday,but in the morning I messed up something.Still project is running but not displaying any image.
    All the images are there actual place.
    Please help me to figure it out the problem.

    Thanks

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Show your image–loading code.

  3. #3
    Java.child is offline Member
    Join Date
    Sep 2008
    Posts
    32
    Rep Power
    0

    Default

    Hi,

    ReturnMainCRVM.setName( "ReturnMainCRVM" );
    add( ReturnMainCRVM );
    ReturnMainCRVM.setVisible( true );
    ReturnMainCRVM.setEnabled( true );
    ReturnMainCRVM.setRequestFocusEnabled( true );
    ReturnMainCRVM.setTabOrder( 2 );
    //unsup ReturnMainCRVM.FontUnderline = false;
    ReturnMainCRVM.setToolTipText( "Return" );
    //unsup ReturnMainCRVM.HelpContextID = 0;
    ReturnMainCRVM.setText( "" );
    ReturnMainCRVM.setDefaultButton( false );
    //unsup ReturnMainCRVM.Cancel = false;
    ReturnMainCRVM.setIcon( new ImageIcon("resources/CRVMApp_ReturnMainCRVM_Picture.jpg") );
    ReturnMainCRVM.setLocation( 1024, 680 );
    ReturnMainCRVM.setSize( 104, 28 );
    ReturnMainCRVM.setFont( new Font("SansSerif", Font.PLAIN, 11) );




    I guess you are talking about this section of code.If not please ask me again.

    Thanks

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,402
    Rep Power
    25

    Default

    new ImageIcon("resources/CRVMApp_ReturnMainCRVM_Picture.jpg") );
    This is the code that would load an image.
    Have you tested that there is an image being loaded ok by the ImageIcon class?
    Now where is the code that displays the image?
    What is the ReturnMainCRVM class?

  5. #5
    Java.child is offline Member
    Join Date
    Sep 2008
    Posts
    32
    Rep Power
    0

    Default

    Thanks for quick response.
    This is the project which is running from the long time.So I guess there is not a problem with code.
    I was checking what are the options in build path and clicked on some thing.After that images are goen from the project.
    One more thing i need to mention that in eclipse resourse folder changed its position.Does the order matters?

  6. #6
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    resourse folder changed its position.Does the order matters
    Yes, it most likely does.
    Why? Because you have given a specific address for the image to the ImageIcon constructor:
    resources/CRVMApp_ReturnMainCRVM_Picture.jpg
    This tells Java to look in the "resources" folder for the image file named "CRVMApp_ReturnMainCRVM_Picture.jpg". It expects the "resources" folder will be found in the current folder.
    If you change this to the new folder address/path/location java will know where to look for the image.

    Another option is to let the ClassLoader look up the image for you:
    Java Code:
    String resource = "resources/CRVMApp_ReturnMainCRVM_Picture.jpg";
    URL url = getClass().getResource(resource);
    // or
    url = getClassLoader().getResource(resource);
    For more about this see Loading Images Using getResource in How to Use Icons.

Similar Threads

  1. profiling - execution statistics tab missing
    By quitequick in forum Eclipse
    Replies: 3
    Last Post: 07-29-2008, 01:38 PM
  2. Missing text encoding
    By talgreen in forum Eclipse
    Replies: 0
    Last Post: 03-30-2008, 08:14 PM
  3. IOExceptions and missing JavaDoc
    By tim in forum NetBeans
    Replies: 0
    Last Post: 01-29-2008, 12:55 PM
  4. is it bug? or am i missing a point?
    By blowguy in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 06:19 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
  •