This Java awt (Abstract Windowing Toolkit) tutorial describes about the image size. This is an actual representation of object. Simply, it helps us to feel associated with an object on the frame. Some images are either 'literal' images that are unequally create and involve little or no extension of the various meaning of the words that are used to express them or 'figurative' images that do not follow the literal meaning of the worlds completely.
Description of program:
This program helps you in setting an image and getting the size of its. For setting an image on the frame, you will need an image that have to be added in the MediaTracker object with the help of addImage() method. After adding you will get the size of image (width and height) through the getWidth() and getHeight() method. Here you will see the frame's size are arranged according to the size of image. You will try and get it.
Description of code:
This is the constructor of Toolkit class that is the abstract super class of all exact implementation of awt. The various components are bounded by subclass of Toolkit to a particular native toolkit implementations.
This method returns the default toolkit and if could not be found it then it will thrown by the AWTError.
This method gets pixels data from the given file name that has the extension either GIF, JPEG or PNG and returns an image in pixels. It takes string type file name that is the name of an image.
This is the constructor of MediaTracker class that is a utility class for tracking the status of a number of media objects that include an audio clips as well as images but only images are supported in current time.
This method is used to start the loading all images with the help of media tracker to specified identifier that are given by user.
This method returns the width of displaying images in pixels.
This method returns the height of displaying images in pixels.
Here is the code of program:
Output of program:
Size of an image:
The width of image: 300
The height of image: 224
Liked it! Share this Tutorial