the method that deals with the pictures
private void jList1ListSelectionValueChanged(ListSelectionEvent event) { String file = (String) shopItems.getSelectedValue(); int item = itemColorList.getSelectedIndex(); try { URL picUrl = new URL(getCodeBase(), "/Resources/TCC/pics/"+ file + "/"); Image pic = getImage(picUrl, (item+1)+ ".gif"); shopPictures.addPic(pic); shopPictures.repaint(); } catch (Exception e) { e.printStackTrace(); } }
the shopPictures (PicturePanel) class
package ernya; import java.awt.Graphics; import java.awt.Image; import javax.swing.JPanel; public class JPicturePanel extends JPanel { Image pic = null; private static final long serialVersionUID = 1L; public JPicturePanel() { initComponents(); } private void initComponents() { setSize(55, 55); } public void addPic(Image picture){ pic = picture; } public void paint(Graphics g){ g.drawImage(pic,0,0,this); } }