I need copy icon and string from one JList to another JList.
All the icons and strings are already shown in the first JList on the interface. But, when I select the icon and string from the first JList and then click the add button, the second JList shows: null (no image available).
The following is the code segment, could any one help have a look and find the problem?
imageList = new JList(intArray); imageListRenderer imageRenderer= new imageListRenderer(); imageRenderer.setPreferredSize(new Dimension(200, 125));
imageList.setCellRenderer(imageRenderer); imageList.setVisibleRowCount(7); imageList.setFixedCellHeight(125); imageList.setLayoutOrientation(JList.HORIZONTAL_WRAP); imageList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); JScrollPane imageScrollPane1 = new JScrollPane(imageList);
One probabilty can be your condition if (event.getSource() == addPersonButton) { } is not getting satisfied and the control is not going inside this condition.
Try a System.out.println() inside the condition to make sure that the cntrl goes into the if condition.