1 19 20 package org.netbeans.modules.j2ee.persistence.wizard.fromdb; 21 22 import java.awt.Component ; 23 import javax.swing.DefaultComboBoxModel ; 24 import javax.swing.DefaultListCellRenderer ; 25 import javax.swing.JComboBox ; 26 import javax.swing.JList ; 27 import org.netbeans.api.project.SourceGroup; 28 29 33 public class SourceGroupUISupport { 34 35 private SourceGroupUISupport() { 36 } 37 38 public static void connect(JComboBox comboBox, SourceGroup[] sourceGroups) { 39 comboBox.setModel(new DefaultComboBoxModel (sourceGroups)); 40 comboBox.setRenderer(new SourceGroupRenderer()); 41 } 42 43 private static final class SourceGroupRenderer extends DefaultListCellRenderer { 44 45 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 46 Object displayName = null; 47 48 if (value instanceof SourceGroup) { 49 displayName = ((SourceGroup)value).getDisplayName(); 50 } else { 51 displayName = value; 52 } 53 54 return super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus); 55 } 56 } 57 } 58 | Popular Tags |