0
我創建了一個組件在jPanel
中顯示圖片。但它在設計時沒有顯示圖片time.how在設計時顯示圖片?在設計時顯示圖片
public class JImagePanel extends JPanel {
private BufferedImage _img=null;
public JImagePanel() {
super();
}
public void setImage(URL img) {
try{
this._img = ImageIO.read(img);
validate();
repaint();
}catch(Exception err){
}
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if(this._img!=null)
g.drawImage(_img, 0, 0, getWidth(), getHeight(), this);
}
}