Are there any advantages of using JLabel over Image?
If all you want to do is display an image at its actual size then use a JLabel so you don't reinvent the wheel.
And when I should use Image?
If you want to customize the painting of the image. Maybe to do dynamic scaling, tiling, rotations etc.
An Image
is not a Swing component but a JLabel
with an ImageIcon
is. So when you want to place your Image
to a regular Swing container you have to use a JLabel
. But there are other ways to decorate an Image
to become a Component
, JXImagePanel
from the SwingX project is an example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.