• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

dynamic...strings...

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey, hard to explain what im trying to do but let me just show you...



but it wont let me use +imagesLoaded+1+ cause it says i can only pass a string. is there a way that i could get my desired effect here?
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing at what you want here but...

BufferedImage img = getImage("/bg1/bgTesti" + (imagesLoaded+1) + ".png");
 
Evan Pierce
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure is.
 
Evan Pierce
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok im having another problem with that piece of code. my images are saved with names like bgTesti_00001.png and my code above would only make bgTesti_1.png (already fixed underscore problem).

what would one do to shift the 1 over 4 spots?
thanks.
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ July 25, 2006: Message edited by: Lynette Dawson ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Java 5, you can use String.format(...) to format a number with leading zeroes:

[ July 26, 2006: Message edited by: Jesper Young ]
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic