2011-03-13 62 views

回答

7

看一看这个教程:Handling Images in a Java GUI Application

与此同时,你可以代码以及:

JPanel panel = new JPanel(); 
ImageIcon icon = new ImageIcon("image.jpg"); 
JLabel label = new JLabel(); 
label.setIcon(icon); 
panel.add(label); 
3

可以使用的ImageIcon和JLabel的:

ImageIcon icon = createImageIcon("image.gif", "sample image"); 

// Label with text and icon 
JLabel label1 = new JLabel("Image and Text", icon, JLabel.CENTER); 

// Label with icon only 
JLabel label2 = new JLabel(icon); 

// Add to your JPanel 
panel.add(label1); 
panel.add(label2); 
2

1)首先将图像粘贴到应用程序文件夹 2)标签添加到面板 3)右击无标记>属性 4)选择Icon->更多选项 5)选择包和文件,并点击oK 6)UR DONE :)