2015-10-20 86 views
1

我有一个非常大的图像,但我想在jabel中使用jLabel属性在jLabel中调整它。如果可能,请帮助我。如何在JAVA Netbeans中调整jLabel中的图片大小?

+0

对于[示例](http://stackoverflow.com/questions/22679717/resizing-image-to-fit-in-jlabel/22680573#22680573),[示例](http://stackoverflow.com/questions/18010803/java-swing-resize-imageicon -with-to-jlabel/18011430#18011430),[example](http://stackoverflow.com/questions/18351186/resizing-jlabel-imageicon-with-html/18352000# 18352000),[示例](http://stackoverflow.com/questions/11698271/how-to-make-jlabel-with-image-fill-borderlayout-center/11698479#11698479)。简短的回答是,你需要把你的手弄脏 – MadProgrammer

回答

1

您可以使用Image.getScaledInstance(...)方法将图像缩放到所需的大小。

然后,您使用图像创建ImageIcon,并将图标添加到JLabel

编辑:

您也可以尝试使用达里尔的Stretch Icon。如果您使用适当的布局管理器,则使用此类将在框架大小调整时动态调整图标大小。

+0

你能举个例子吗? –

+0

@VipulKumar对于[示例](http://stackoverflow.com/questions/22679717/resizing-image-to-fit-in-jlabel/22680573#22680573),[示例](http://stackoverflow.com/questions/18010803/java-swing-resize-imageicon -with-to-jlabel/18011430#18011430),[example](http://stackoverflow.com/questions/18351186/resizing-jlabel-imageicon-with-html/18352000# 18352000),[示例](http://stackoverflow.com/questions/11698271/how-to-make-jlabel-with-image-fill-borderlayout-center/11698479#11698479)。简短的回答是,你需要把你的手弄脏 – MadProgrammer

+0

@Camickr你的可调整大小的图标的链接在哪里? – MadProgrammer