对于Java swing,我尝试在面板中添加图像并使用JLabel创建图像。
JLabel imageLabel = new JLabel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
BufferedImage bi = ImageIO.read(imageInputStream);
double scale = 50 / bi.getHeight();
g2.scale(scale, scale);
g2.drawImage(bi, 0, 0, null);
}
}
在网上
<img src="imageURL" hieght="50"/>
为什么Swing绘制图像,其质量不如网页。为什么呢?