• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 704
  • Last Modified:

setWidth setHeight


How to set the image width and height?

((Image)lines.elementAt(k)).setWidth(100);
((Image)lines.elementAt(k)).setHeight(100);
g.drawImage((Image)lines.elementAt(k), x, y, this);

ERROR:
 cannot resolve symbol
symbol  : method setWidth (int)
location: class java.awt.Image
((Image)lines.elementAt(i)).setWidth(100);
^

cannot resolve symbol
symbol  : method setHeight (int)
location: class java.awt.Image
((Image)lines.elementAt(i)).setHeight(100);
^
2 errors
0
tloip
Asked:
tloip
1 Solution
 
BreadstickCommented:
You don't set the width and height on the Image object, you tell Graphics the width and height that you want to draw them it:

int width = 100;
int height = 100;
g.drawImage((Image)lines.elementAt(k), x, y, width, height this);
0
 
aviadbdCommented:

You can use the ReplicateScaleFilter class.

It has a "setDimensions()" method and you can use it to set the new dimensions of your image.

See

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/FilteredImageSource.html
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/ReplicateScaleFilter.html

AviadBD.
0
 
tloipAuthor Commented:
Oh...i got it. Thanks
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now