Solved

setWidth setHeight

Posted on 2004-10-20
3
668 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Server Faces parameter pass? 6 50
VB Script to add site to Java Exception List 4 80
check java version using powershell 13 95
mysql jsp example issue 32 38
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

831 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