Results 1 to 2 of 2
  1. #1
    Vinny2110 is offline Member
    Join Date
    Dec 2010
    Rep Power

    Default Background image in Jwindow

    Hello, im doing this project for school. Now i have to build a splash screen for my program but i don't know how to put an image at the background, and my text has to come above it.

    Java Code:
    public class SplashScreen extends JWindow {
        private int tijd;
        private JLabel lblInfo;
        private JPanel pnlContent;
        public SplashScreen(int tijd){
            this.tijd = tijd;
        public void initialiseerComponenten(){
            lblInfo = new JLabel("Copyright 2011, Jonas Meel & Vincent Huysmans");
            pnlContent = new JPanel();
        public void layoutComponenten(){
            pnlContent = (JPanel)getContentPane();
            //onderstaande code zorgt ervoor dat de splashscreen steeds in het midden van het scherm staat
            int w = 500;
            int h =300;
            Dimension scherm = Toolkit.getDefaultToolkit().getScreenSize();
            int x = (scherm.width-w)/2;
            int y = (scherm.height-h)/2;
            pnlContent.add(lblInfo, BorderLayout.SOUTH);
        public void toonSplash(){
            try { Thread.sleep(tijd); } catch (Exception e) {}
    Sorry for my grammar im from Belgium

  2. #2
    mr_guy is offline Member
    Join Date
    Feb 2011
    Rep Power


    use the 'paint' method to draw an image on the window. Make sure that at the end of the method you call 'super.paintComponents()' and that you make any panels or other components going in the window transparent.

Similar Threads

  1. [Help] W/ background image
    By gundum584 in forum New To Java
    Replies: 9
    Last Post: 01-10-2011, 05:48 AM
  2. JApplet background image
    By footballHunter in forum New To Java
    Replies: 1
    Last Post: 11-24-2010, 02:46 AM
  3. Background image
    By leiferouis in forum New To Java
    Replies: 9
    Last Post: 03-08-2009, 05:49 PM
  4. Image as background
    By Java.child in forum AWT / Swing
    Replies: 2
    Last Post: 10-02-2008, 11:37 PM
  5. Image with JWindow -> trails
    By ofir3dvb in forum AWT / Swing
    Replies: 2
    Last Post: 03-18-2008, 05:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts