How to bring an image to the foreground in Java? -


i'm trying create pacman game in java, , far i've displayed background image (the blue , black maze), i'm having trouble showing image of pacman. when try display him in same method displayed background, doesn't appear unless manually alter size of jframe. , when appears there's small white square in bottom right corner of image. can fix this? there other way can insert pacman image in works?

this code:

  jframe window = new jframe();    imageimplement pacman = new imageimplement(new imageicon("c:\\users\\16ayoubc\\desktop\\pacman-moving.gif").getimage());     imageimplement panel = new imageimplement(new imageicon("c:\\users\\16ayoubc\\desktop\\background.png").getimage());    pacman.setlocation(255, 255);   pacman.setvisible(true);   pacman.setopaque(true);   window.add(pacman);   window.add(panel);    window.setvisible(true);   window.setsize(576,655);   window.setname("pacman");   window.setdefaultcloseoperation(jframe.exit_on_close); 

use jlayeredpane insted of window directly container , specify depth (z-order) of components when add them.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -