Code example for JList

Methods: getSelectedIndex

0
	if (! e.getValueIsAdjusting() && source instanceof JList) {
	    JList sourceList = (JList) source;
	    // save last displayed component 
	    saveLastDialog(); 
	    // load other panel if an index is selected 
	    int idx = sourceList.getSelectedIndex();
	    if (idx >= 0) {
		AddonPanel panel = getPanel(idx);
		lastActivePanel = panel;
		container.removeAll();
		container.add(panel, BorderLayout.CENTER);
		// invalidate component, else it won't be redrawn 
		container.invalidate();
		container.validate();
		container.repaint();
		// update icon in management panel 
		dialog.setLogo(panel.getLogo());
	    } 
	} 
    } 
Experience pair programming with AI  Get Codota for Java