jnhs

Icon icon = new ImageIcon("src\\resource\\" + jTFimgName.getText()); jLabColor.setIcon(icon);

小图片正常显示

但是大图不行,大图会把整个屏幕撑满,这一点真不如vs,c#窗体程序有画布,画布可以对图像进行各种设定

java里边就不行

但是也能凑合用

首先,把jlabel放在jpanel的左上角

这样,图像就能盛满jpanel了

比如,我放了3个jpanel

 ImageIcon colorIcon = new ImageIcon("src\\resource\\" + jTFimgName.getText());
            colorIcon.setImage(colorIcon.getImage().getScaledInstance(320, 240, Image.SCALE_DEFAULT));//宽高根据需要设定    
            jLabColor.setIcon(colorIcon);

 

 

分类:

技术点:

相关文章:

  • 2022-01-01
  • 2022-12-23
  • 2021-04-14
  • 2021-09-10
  • 2022-02-13
  • 2021-04-24
  • 2021-06-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2021-10-16
相关资源
相似解决方案