Welcome to Dream.In.Code
Become a Java Expert!

Join 150,027 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,558 people online right now. Registration is fast and FREE... Join Now!




need help using Jcreator

 
Reply to this topicStart new topic

need help using Jcreator, program not showing images

cybernaut09
12 Jun, 2008 - 10:26 AM
Post #1

New D.I.C Head
*

Joined: 1 Jun, 2008
Posts: 20


My Contributions
I wrote a program in java which has images using notepad , and it was working properly. My project folder contained the source file and a resource folder with images. Now I am trying the same project in Jcreator but its not running properly as images are not showing. JCreator has created a project folder which contain folders like this structure:-

1. JUMP
1.1 classes
1.2 src
1.3 resources

The resources folder is created by me and contains images used in the program.So please tell me where I am wrong in this program. I have tried 2 different links but nothings working.Here's the part of the full program.
CODE

class jumpAbout extends JFrame
{
public jumpAbout()
{
  super("Project");
  JPanel mjp =new JPanel(){
     ImageIcon backImage = new ImageIcon("JUMP/resources/whitebg.jpg");//***image is not showing***
     Image image = backImage.getImage();
     {setOpaque(false);}
     //Override
     public void paintComponent (Graphics g) {
       g.drawImage(image, 0, 0, this);
       super.paintComponent(g);
     }
   };               //main pannel for info
  mjp.setLayout(new BorderLayout());
  mjp.add(new JLabel(new ImageIcon("/resources/about.gif")),BorderLayout.WEST); //***image is not showing***
  JLabel info = new JLabel("project",JLabel.CENTER);
  info.setFont(new Font("Serif", Font.BOLD, 14));
  info.setForeground(Color.RED);
  mjp.add(info,BorderLayout.CENTER);
  add(mjp);
  }


This post has been edited by cybernaut09: 12 Jun, 2008 - 10:31 AM
User is offlineProfile CardPM
+Quote Post

mensahero
RE: Need Help Using Jcreator
12 Jun, 2008 - 10:29 AM
Post #2

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
QUOTE

1. ProjectFolder
1.1 classes
1.2 src
1.3 resources


I can't see any JUMP folder directory in there.. blink.gif

Try moving the resources folder.. inside the src folder..

This post has been edited by mensahero: 12 Jun, 2008 - 10:31 AM
User is offlineProfile CardPM
+Quote Post

cybernaut09
RE: Need Help Using Jcreator
12 Jun, 2008 - 10:34 AM
Post #3

New D.I.C Head
*

Joined: 1 Jun, 2008
Posts: 20


My Contributions
QUOTE(mensahero @ 12 Jun, 2008 - 11:29 AM) *

QUOTE

1. ProjectFolder
1.1 classes
1.2 src
1.3 resources


I can't see any JUMP folder directory in there.. blink.gif

Try moving the resources folder.. inside the src folder..

I have corrected my post...I by mistake wrote JUMP folder as ProjectFolder .
I hope now you would be able to help me. Tried moving the resources folder inside the src folder but its not working for me.
Thanks

This post has been edited by cybernaut09: 12 Jun, 2008 - 10:38 AM
User is offlineProfile CardPM
+Quote Post

mensahero
RE: Need Help Using Jcreator
12 Jun, 2008 - 10:38 AM
Post #4

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
Yeah I see.. but did you try.. moving all your images file.. inside the src folder..

well I've encounter this problem.. when im using the imageIcon method..

the src folder contains all your class files... you should try moving your resource folder inside it.. making src as the parent directory..

It should be..

1. src
1.1 resource

IMO that would work.. blink.gif

This post has been edited by mensahero: 12 Jun, 2008 - 10:39 AM
User is offlineProfile CardPM
+Quote Post

cybernaut09
RE: Need Help Using Jcreator
12 Jun, 2008 - 10:45 AM
Post #5

New D.I.C Head
*

Joined: 1 Jun, 2008
Posts: 20


My Contributions
QUOTE(mensahero @ 12 Jun, 2008 - 11:38 AM) *

Yeah I see.. but did you try.. moving all your images file.. inside the src folder..
<<yes I did

well I've encounter this problem.. when im using the imageIcon method..
the src folder contains all your class files...
<<src folder contains .java files. classes folder contain .class files

you should try moving your resource folder inside it.. making src as the parent directory..
It should be..
1. src
1.1 resource
IMO that would work.. blink.gif
<<I tried but still not working now my JUMP folder looks
1.JUMP
1.1 classes
1.2 src
1.2.1 resources
and I have tried all these links "resources/about.gif","/resources/about.gif","src/resources/about.gif"...but nothings working. If you want I can upload all the files I have made.


User is offlineProfile CardPM
+Quote Post

mensahero
RE: Need Help Using Jcreator
12 Jun, 2008 - 11:19 AM
Post #6

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
Yep.. post the whole code.. including the main.. and I'll test it with my images here when I wake up tomorrow.. its 3:16 am now.. lmao.. blink.gif

Good Luck...

I've test it.. before I tried to sleep.. it does compile.. but the class doesn't work.. it doesn't even show a JFRAME window.. not sure though.. better get some rest..

well are you seeing a JFRAME? or not?

This post has been edited by mensahero: 12 Jun, 2008 - 11:27 AM
User is offlineProfile CardPM
+Quote Post

cybernaut09
RE: Need Help Using Jcreator
12 Jun, 2008 - 11:51 AM
Post #7

New D.I.C Head
*

Joined: 1 Jun, 2008
Posts: 20


My Contributions
QUOTE(mensahero @ 12 Jun, 2008 - 12:19 PM) *

Yep.. post the whole code.. including the main.. and I'll test it with my images here when I wake up tomorrow.. its 3:16 am now.. lmao.. blink.gif
Good Luck...

As you have asked me , I am uploading all my coding.
The forum was not allowing me to upload in .rar extension , so I have changed it to .txt . Please change it to .rar again after downloading.
rar file contains 2 folders - jump and jump0
jump is created by JCreator for the project.( not working - does not show images)
jump0 contains program created using simple notepad (working - just run jump.java)

Thanks in advance.


Attached File(s)
Attached File  project.txt ( 29.37k ) Number of downloads: 15
User is offlineProfile CardPM
+Quote Post

pbl
RE: Need Help Using Jcreator
12 Jun, 2008 - 02:52 PM
Post #8

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,585



Thanked: 233 times
Dream Kudos: 75
My Contributions
Don't know about JCreator, I used Eclipse.

Both JCreator and Eclipse manage "projects".

In the case of Eclipse (and may be JCreator is the same that is why I posted this reply) you cannot just copy a file (image, source, data) into one of the folder because the "project manager" won't be informed of this new file. You have to:
Use Eclipse file menu and then explicity specify what you want to import
File
- import
--- image
--- source
--- data
--- jar
--- classes
--- and so on
User is online!Profile CardPM
+Quote Post

mensahero
RE: Need Help Using Jcreator
12 Jun, 2008 - 04:59 PM
Post #9

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
QUOTE

As you have asked me , I am uploading all my coding.
Thanks in advance.


Here's your new code bro..I've added a simple snippet.. it now works..
CODE

    import javax.swing.JFrame;
    import javax.swing.Icon;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.ImageIcon.*;
    import javax.swing.border.*;
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.URL;

    class jumpAbout extends JFrame
    {
    public jumpAbout()
    {
      super("Project");
      JPanel mjp =new JPanel(){
         ImageIcon backImage = createImageIcon("resources/whitebg.jpg");//***image is not showing***
         Image image = backImage.getImage();
         {setOpaque(false);}
         //Override
         public void paintComponent (Graphics g) {
           g.drawImage(image, 0, 0, this);
           super.paintComponent(g);
         }
       };               //main pannel for info
      mjp.setLayout(new BorderLayout());
      mjp.add(new JLabel(createImageIcon("resources/about.gif")),BorderLayout.WEST); //***image is not showing***
      JLabel info = new JLabel("project",JLabel.CENTER);
      info.setFont(new Font("Serif", Font.BOLD, 14));
      info.setForeground(Color.RED);
      mjp.add(info,BorderLayout.CENTER);
      add(mjp);
      }

        protected ImageIcon createImageIcon(String path) {

                   ImageIcon tempImg;
                   URL imgURL = getClass().getResource(path);

                   tempImg = (imgURL != null) ? new ImageIcon(imgURL): null;
                   return tempImg;
               }

}


blink.gif ... I've added a simple method.. blink.gif

directory must be:

1. src
1.1 resources


QUOTE

In the case of Eclipse (and may be JCreator is the same that is why I posted this reply) you cannot just copy a file (image, source, data) into one of the folder because the "project manager" won't be informed of this new file.


In my IDE I just copy/paste my resources, classes, from directory into another directory.. and it works fine.. my IDE spoils me.. blink.gif lmao


This post has been edited by mensahero: 12 Jun, 2008 - 05:03 PM
User is offlineProfile CardPM
+Quote Post

pbl
RE: Need Help Using Jcreator
12 Jun, 2008 - 05:05 PM
Post #10

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,585



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(mensahero @ 12 Jun, 2008 - 05:59 PM) *

In my IDE I just copy/paste my resources, classes, from directory into another directory.. and it works fine.. my IDE spoils me.. blink.gif lmao


You paid for it (or run an illegal copy) mine is free and legal biggrin.gif

User is online!Profile CardPM
+Quote Post

mensahero
RE: Need Help Using Jcreator
12 Jun, 2008 - 05:07 PM
Post #11

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions

QUOTE


You paid for it (or run an illegal copy) mine is free and legal biggrin.gif



blink.gif I've asked for it.. and they gave it to me.. I've just begged and say please.. biggrin.gif blink.gif lmao.. I love my instructors..

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 09:29PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month