Solved

setWidth setHeight

Posted on 2004-10-20
3
666 Views
Last Modified: 2010-07-27

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
Comment
Question by:tloip
3 Comments
 
LVL 2

Accepted Solution

by:
Breadstick earned 30 total points
ID: 12366695
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
 
LVL 3

Expert Comment

by:aviadbd
ID: 12366699

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
 

Author Comment

by:tloip
ID: 12366716
Oh...i got it. Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now