Click to See Complete Forum and Search --> : Image


davey
06-18-2005, 11:48 PM
what would be the best way of making a background image for this ?
(any other dumb errors you see please tell me as i am just learning java thanks)
package KickBoxer;
import java.awt.*;
import javax.swing.*;
public class KBLoader {
public KBLoader() {
JFrame splash = new JFrame("Kick Boxer Splash");
Container splashpane = splash.getContentPane();

splash.setDefaultCloseOperation(2);
splashpane.setBackground(Color.BLACK);
splash.pack();
splash.setSize(800,600);
splash.show();
}

}

buntine
06-19-2005, 12:02 AM
You will have to override the paint or paintComponent method to draw the background.

package KickBoxer;

import java.awt.*;
import javax.swing.*;

public class KBLoader
{
ImageIcon img;
public KBLoader()
{
img = new ImageIcon("YourImageName.jpg");
JFrame splash = new JFrame("Kick Boxer Splash");
Container splashpane = splash.getContentPane();

splash.setDefaultCloseOperation(2);
splashpane.setBackground(Color.BLACK);
splash.pack();
splash.setSize(800,600);
splash.show();
}

protected void paintComponent(Graphics g)
{
Dimension d = getSize();
g.drawImage(img.getImage(), 0, 0, d.getWidth(), d.getHeight(), null);
super.paintComponent(g);
}
}


Something like that should get you on the right track.

Regards.

davey
06-19-2005, 06:03 AM
thanks for the help