1 19 package org.netbeans.modules.j2ee.websphere6.ui; 20 21 import javax.swing.*; 22 import java.util.*; 23 24 32 public class InstancesModel extends AbstractListModel 33 implements ComboBoxModel { 34 37 private Vector instances; 38 39 42 private int selectedIndex = 0; 43 44 49 public InstancesModel(Vector instances) { 50 this.instances = instances; 52 53 this.selectedIndex = 0; 55 } 56 57 62 public void setSelectedItem(Object item) { 63 selectedIndex = instances.indexOf(item); 66 } 67 68 75 public Object getElementAt(int index) { 76 return instances.elementAt(index); 77 } 78 79 84 public int getSize() { 85 return instances.size(); 86 } 87 88 93 public Object getSelectedItem() { 94 if (instances.size() == 0) { 96 return null; 97 } 98 99 return instances.elementAt(selectedIndex); 101 } 102 } 103 | Popular Tags |