Solved

setWidth setHeight

Posted on 2004-10-20
3
674 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

707 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