用Java处理图像,而不是标签

[英]Handling Images in Java , Not Label


I would like to know the best way for handling the images in Java. Till now i am doing so using ImageIcon of JLabel but i dont find the approach right as label does not has stretch property like an vb6 imagebox which automatically stretch the image to fit the container ..

我想知道在Java中处理图像的最佳方法。直到现在我正在使用JLabel的ImageIcon,但我没有找到正确的方法,因为标签没有像vb6图像框那样的拉伸属性,它会自动拉伸图像以适应容器。

Please tell me the best way .. Also mention any external library or component i can install for same . I would prefer a free library..

请告诉我最好的方法..还提到我可以安装的任何外部库或组件。我更喜欢免费图书馆..

Also i tried swingfx library but it was not good enough

我也试过swingfx库,但还不够好

1 个解决方案

#1


1  

the simple answer is you can just create a subclass of JPanel (or Canvas if you're working in awt) and in the paintComponent method (paint in the awt world), draw the image doing any scaling/skewing/translation you want.

简单的答案是你可以创建JPanel的子类(或者如果你在awt中工作的Canvas)和paintComponent方法(在awt世界中绘画),绘制图像进行你想要的任何缩放/倾斜/翻译。

How to make canvas with Swing?

如何用Swing制作画布?


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/01/21/2916e05d0e1ec91b1c9fecf6c6685a70.html



 
  © 2014-2022 ITdaan.com 联系我们: