• 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

Putting variable text over a splash screen

 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a splash screen at the start of my program:

It is simply a small image with the name of the software. I want to include a variable tagline underneath the software logo (e.g. an image of the windows logo with text below reading "Crushing competition since 1983" or something like that). This tag line will be randomly selected at runtime. I would prefer not to have to generate multiple images, since that will take up a lot of memory. How can I do this?
Can I overlay a transparent slpash screen with the text? Can I add text to the image dynamically? Can I embed the image in a headless window and overlay a glass pane with text? Any other ideas?
--Mark
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think what you can do is override the paintComponent method of your Window or Panel (depending on where you want your image). Then, when you add your JLabel it will display on top of your image. And you can dynamically choose your JLabel text at runtime if you wish.

Something like that for the overridden painComponent method. Where yourImage is an Image object. Hope that helps.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark,

This depends on the JCSplashScreen class... is this your class, do you have the source, can you extend it? If any of these are the case, either modify or extend the class to allow you to set a String and also modify the paintComponent() method to draw a string over the image using the drawString() method of Graphics.

Even if you don't have the code to the class, and can't override it, you can make a BufferedImage of your image and draw the string on that, then send the buffered image to the splash screen class.

If you need any help on either of these approaches, just post your questions!
 
reply
    Bookmark Topic Watch Topic
  • New Topic