Solved

setWidth setHeight

Posted on 2004-10-20
3
663 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
Comment Utility
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
Comment Utility

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
Comment Utility
Oh...i got it. Thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
powerN  challenge 3 46
firstChar challenge 13 83
Eclipse Neon and jdk 1.8.0 11 64
What is the latest versions eclipse neon 2 116
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 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

11 Experts available now in Live!

Get 1:1 Help Now