• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting a background image through ImageIO gives a `save problem` upon compilation

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

Screenshot-(245).png
[Thumbnail for Screenshot-(245).png]
The `save` problem upon compilation
Screenshot-(247).png
[Thumbnail for Screenshot-(247).png]
When I clicked on `save as UTF-8`, it threw an exception
Screenshot-(246).png
[Thumbnail for Screenshot-(246).png]
A pic to get an idea of how the window is
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Sophia Green
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Acetylsalicylic acid is aspirin. This could be handy too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic