if (selected != -1) { m_ListModel.insertElementAt(m_ElementEditor.getValue(), selected); } else { m_ListModel.addElement(m_ElementEditor.getValue());
Object addObj = m_ElementEditor.getValue();   try { ByteArrayOutputStream bo = new ByteArrayOutputStream(); BufferedOutputStream bbo = new BufferedOutputStream(bo); ObjectOutputStream oo = new ObjectOutputStream(bbo); oo.writeObject(addObj); oo.close();  ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray()); BufferedInputStream bbi = new BufferedInputStream(bi); ObjectInputStream oi = new ObjectInputStream(bbi); addObj = oi.readObject(); oi.close(); if (selected != -1) { m_ListModel.insertElementAt(addObj, selected); } else { m_ListModel.addElement(addObj); } m_Support.firePropertyChange("", null, null); } catch (Exception ex) { JOptionPane.showMessageDialog(GenericArrayEditor.this, "Could not create an object copy", null, JOptionPane.ERROR_MESSAGE);
    public void actionPerformed(ActionEvent e) {      if (e.getSource() == m_DeleteBut) {	int selected = m_ElementList.getSelectedIndex();	if (selected != -1) {	  m_ListModel.removeElementAt(selected);	  if (m_ListModel.size() > selected) {	    m_ElementList.setSelectedIndex(selected);	  }	  m_Support.firePropertyChange("", null, null);	}	if (m_ElementList.getSelectedIndex() == -1) {	  m_DeleteBut.setEnabled(false);	}      } else if (e.getSource() == m_AddBut) {	int selected = m_ElementList.getSelectedIndex();	if (selected != -1) {	  m_ListModel.insertElementAt(m_ElementEditor.getValue(), selected);	} else {	  m_ListModel.addElement(m_ElementEditor.getValue());	}	m_Support.firePropertyChange("", null, null);      }     }