This example is used to create the Image on different location using Canvas class. In this example to create the image we are using following code:
private Image image1, image2, image3;
|
image1 = Image.createImage("/cartoon.png");
|
And for draw the image we are using following code of lines:
| g.drawImage(image1, 0, 0, Graphics.TOP | Graphics.LEFT);
g.drawImage(image2, getWidth() / 2, getHeight() / 2, Graphics.HCENTER | Graphics.VCENTER); g.drawImage(image3, getWidth(), getHeight(), Graphics.BOTTOM | Graphics.RIGHT); |
The application is as follows:

Source Code of ImageItemExample2.java
import java.io.IOException;
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Image Icon Using Canvas Example View All Comments
Post your Comment