I am trying to set a background image for this window and I have tried multiple ways but I am compiling/saving it, it's giving an error as shown in the first pic.
Here is my code:
I have added images on the window using `setIcon` but I didn't get this problem upon compilation. Even when I am commenting out all the lines added for the background image, I am getting the same error. Only when I remove it that I am able run it.
Can someone give me alternative ways of how I can set a background image for this?
Sophia Green wrote:I have added images on the window using `setIcon` but I didn't get this problem upon compilation.
Look at the quote characters you used in that sentence. Those aren't standard characters which appear in CP-1252, which is a standard Western European character set which you chose (by default probably) to express your code in. So probably you used non-standard quote characters like that somewhere in your code.
If your code compiled correctly, then maybe your non-standard characters are in comments, or something like that. Anyway you should search them out and replace them.
Here is how it worked for me:
I loaded the image(simple-blue.jpg) I used in another new program and it didn't work at first, then added a new image in the same program and it worked. Then I added the first image to the same new program and somehow it worked. I added the image path simple-blue.jpg in the program which I posted here again and I don't know how but it worked!
Sophia Green wrote:Here is how it worked for me:
I loaded the image(simple-blue.jpg) I used in another new program and it didn't work at first, then added a new image in the same program and it worked. Then I added the first image to the same new program and somehow it worked. I added the image path simple-blue.jpg in the program which I posted here again and I don't know how but it worked!
When I pasted your first posting of code into Eclipse it complained about the first set of double quotes. I re-typed them and everything was ok.