...

View Full Version : Image Object not Displaying



Dornith
02-24-2012, 11:31 PM
I am working on a game and I like to make my own graphics using images from Photoshop and Illustrator. I have the imaged but they don't show up.


class ImageComponent extends JPanel
{//Allows for images to be used as components or buttons
Image ImagUp;
double Width;
double Height;
private static Container Window;
private static int WindSize;

public ImageComponent(Image ImageUp, double Width, double Height, Container O)
{
this.ImagUp = ImageUp;
this.Width = Width;
this.Height = Height;
WindSize = Math.min(O.getHeight(), O.getWidth());
this.setPreferredSize(new Dimension((int) (WindSize * Width), (int) (WindSize * Height)));
this.setBackground(new Color(0,0,0,0));
Window = O;
}

public void paintComponent(Graphics g)
{
super.paintComponent(g);
WindSize = Math.min(Window.getHeight(), Window.getWidth());
g.drawImage(ImagUp, (int) ((WindSize * Width) / 2), 0, (int) (WindSize * Width), (int) (WindSize * Height), this);
}
}


It works for Grid Layout but whenever I try it for anything else it doesn't display. Why is this and how can I fix it?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum