07/10/30 23:17:40
>>455
Iconの拡大縮小に関してだけコメント
>>427はIconがImageIconの場合にしか適用できない方法なので
グラフィックコンテクストに表示倍率を設定してIcon自身に描かせるとかする
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.Icon;
import javax.swing.JLabel;
public class ExtendedJLabel extends JLabel {
public ExtendedJLabel(Icon image) {
super(image);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Icon icon = getIcon();
if (icon != null) {
((Graphics2D)g).scale((double)getWidth() / icon.getIconWidth(), (double)getHeight() / icon.getIconHeight());
icon.paintIcon(this, g, 0, 0);
}
}
}