Jump to content

  • Log In with Google      Sign In   
  • Create Account


Matthew Melendez

Member Since 02 Feb 2012
Offline Last Active Feb 20 2012 11:02 PM

Posts I've Made

In Topic: Java Class Constructor Question

02 February 2012 - 03:20 PM

There won´t be an error. Although it´s not a good programming style.
The better way is to call the constructor of the image in your own constructor like this:

package foo;

import java.awt.Image.*;
import java.awt.image.BufferedImage;
public class foo
{
   BufferedImage image;

		public foo()
		{
				image = new BufferedImage(64,32,BufferedImage.TYPE_INT_ARGB)
		}
		public void setRgb(int x, int y, int rgb)
		{
				image.setRGB(x,y,rgb);
		}
}

Hope I could help you!


I tired that and the setRgb() method can't find the image object. I think it might be out of scope of the setRgb() method.

PARTNERS