Good luck on your next project.
Type: Posts; User: Norm
Good luck on your next project.
No, that is normal.
I assume that a lot of the printouts you are seeing are from the paintComponent method or by methods that the paintComponent method calls. The paintComponent method can be called many times. Each...
The loading of the images done in the getImg method should be moved to the constructor so that the image is only loaded once.
This is wrong. Don't add the + "jpg" in the print out:
...
My code was only meant as an example. You need to write the code that works with your program.
Did you make the changes I suggested? What prints out for the value of the parameter that is used by...
If you are passing the image file filenames to the constructor, next you should check that the constructor is using the filenames correctly to load the files.
Create a String that will be used in...
A suggestion. Simplify your code by passing the image filename to the constructor:
pPink = new Pointer(3600, "pink.jpg");
I'll try to ask very simple questions one at a time to see if you can understand it.
Do you know what an assignment statement is?
Please post some assignment statements that assign values to a...
I think you are wrong there.
I think the image filenames are: "pink.jpg" "weird.jpg" and "rose.jpg"
These are the names of the files on your disk.
I think your problem is that you are using a...
Let's start with a simple question: What are the filenames of the images that you want to view?
The filenames are represented as Strings in your program.
Where in your code is there an...
If you are not interested enough in making your code work to look at it and see where you assign a value to the filename variables, I don't know what else I can do to help you.
Where do you assign...
You are missing my question.
Where do you assign values to the image filename variables?
You assign values to a variable by using an assignment statement like this:
var = "value"; // assign a...
What you posted does NOT give values to the pink, weird and rose variables.
Where do you give them values?
Where do you give a value to the filename arguments that are passed to the Pointer constructor?
Why are they null?
The filename should be a String. The value of a String has NOTHING to do the the contents of a file.
What are the filenames of the images you want to display? Why isn't that filename being passed...
What were you printing out? Look at the print statement again. Was it the filename of the image?
I thought what you were printing was the filename of the image.
Why is your image filename null?
...
Do you understand what that print out is showing?
Are there any images with that name?
As a test, copy and rename one of your images and give it the name: null.jpg
What is printed out? Copy and paste the print out here.
What don't you understand about this request? In your code you call the getResource() method and pass it an argument. Print that out to see what it is.
ImageIcon ii = new...
What I'm trying to help you learn is how to debug your code. If you print out the values of the variables that you are using, you will see what some of the problems are with your code.
Add some...
Add some printlns to print the values the images loaded in Pointer after they have been loaded.
What is printed out???
Also print out the full filename of the image before it is loaded
The constructor's args are messed up. He's mixing apples and oranges to build an image filename.
Move this code to the constructor:
ImageIcon ii = new ImageIcon(this.getClass().getResource(img+".jpg"));
img = ii.getImage();
Did you do this:
Are all the images found and loaded?
Add some printlns to show their values after they have been loaded.
What values were printed out for the images?
If the message did not...
Can you describe what you see when you execute the code?
Are all the images found and loaded? Add some printlns to show their values after they have been loaded.
Your code would be more...