protected Component buildWindowList() {
		ImagePlus img;
		ImageWindow iw;

		// get IDList from WindowManager
		int[] imageIDs = WindowManager.getIDList();		  
		
		if(imageIDs != null) {
			int size;
			if (imageIDs.length < 10) {
				size = imageIDs.length;
			} else {
				size = 10;
			} 
			
			// Initialize window list and vector that maps list entries to window IDs.
			wList = new java.awt.List(size, true);
			vListMap = new Vector();

			// Add Windows to list, select windows, that previously were selected
			for(int n=0; n<imageIDs.length;++n) {
				vListMap.addElement(new Integer(imageIDs[n]));
				wList.add(WindowManager.getImage(imageIDs[n]).getTitle());
				if ( vwins != null && vwins.contains(new Integer(imageIDs[n])) ) {
					wList.select(n);
				}
			}
			// clean vector of selected images (vwins) from images that have been closed,
			if (vwins != null && vwins.size() != 0) {
				for (int n=0; n<vwins.size(); ++n) {
					if(! vListMap.contains(vwins.elementAt(n))) {
						vwins.removeElementAt(n);
						n -= 1;
					}
				}
			}

			wList.addItemListener(this);
			wList.addActionListener(this);
			return (Component)wList;
		}
		else {
			Label label = new Label("No windows to select.");
			wList = null;
			vListMap = null;
			vwins = null;
			return (Component)label;
		}
	}