как правильно добавлять элементы в List?

Имеется панель, по кнопке Add в List добавляется элемент и затем выбираем его значение из списка Choice. Но как только я щелкаю на List и добавляю 2/либо n- элемент, то они скрываются такой синей полоской как на скриншоте. Как исправить данную проблему? Чтобы в AWT.List успешно добавлялись и выбирались из Choice его значения. Помогите пожалуйста. Лучше нужно заменить awt.List на JList. введите сюда описание изображения

Код

    class IndexedValuePanel
        extends
        JPanel
        //implements
        //  ItemListener

{

    IndexedValuePanel()
    {
        //setBackground(Color.white);
        setLayout(new BorderLayout());

        list = new List();
        list.addItemListener( new ItemListener()
                              {
                                  public void itemStateChanged(ItemEvent ie)
                                  {
                                      Object item = ie.getItem();
                                      setCurrentItem(((Integer)item).intValue());
                                  }
                              }
        );
        list.setBackground(Color.white);
        b_newItem = new JButton("Add");
        b_newItem.addActionListener( new ActionListener()
                                     {
                                         public void actionPerformed(ActionEvent e)
                                         {
                                             Object oldValue = getValue();
                                             Object newValue = null;

                                             try
                                             {
                                                 if(oldValue == null || 
                              Array.getLength(oldValue) == 0)
                                                 {
                                             newValue = Array.newInstance(componentType, 1);
                                                 }
                                                 else
                                                 {
                                                int oldLength = Array.getLength(oldValue);
                                 newValue = Array.newInstance(componentType, oldLength + 1);
                                 System.arraycopy(oldValue, 0, newValue, 0, oldLength);
                                                 }
                                             }
                                             catch(NegativeArraySizeException nase)
                                             {
     System.err.println(getClass().getName()+": Cannot instantiate componentType[]: "+nase);
                                             }
                                             //list.add("???");
                                             setValue(newValue);
                                             setCurrentItem(list.getItemCount());
                                             list.add(componentTypeEditor.getAsText());
                                         }
                                     }
        );

        //-------------- currentItemPanel ------------------
        JPanel currentItemPanel = new JPanel();
        //currentItemPanel.setBackground(Color.green);
        currentItemPanel.setLayout(new BorderLayout());
        if (componentTypeEditor.isPaintable() && componentTypeEditor.supportsCustomEditor())
        {
            //view = new PropertyCanvas(frame, componentTypeEditor);
            view = new PropertyCanvas(componentTypeEditor);
        }
        else
        if (componentTypeEditor.getTags() != null)
        {
            view = new PropertySelector(componentTypeEditor);
        }
        else
        if (componentTypeEditor.getAsText() != null)
        {
            view = new PropertyText(componentTypeEditor);
        }
        else
        {
            view = new JLabel("<non-displayabale editor>");
        }
        view.setBackground(Color.lightGray);
        view.setEnabled(false);
        currentItemPanel.add(view, BorderLayout.CENTER);

        add(currentItemPanel, BorderLayout.NORTH);

        JPanel buttonPanel = new JPanel();
        buttonPanel.setBackground(Color.lightGray);
        GridLayout gbl = new GridLayout();
        buttonPanel.setLayout(gbl);
        buttonPanel.add(b_newItem);
        buttonPanel.add(b_remove);
        buttonPanel.add(b_moveUp);
        buttonPanel.add(b_moveDown);
        add(buttonPanel, BorderLayout.SOUTH);


    }

    private void init()
    {
        if(!isInited)
        {
            if(indexedPropertyValue != null)
            {
                int count = Array.getLength(indexedPropertyValue);
                if(count > 0)
                {
                    list.removeAll();
                    for(int i = 0; i < count; ++i)
                    {
                        setCurrentItem(i);
                        String s = componentTypeEditor.getAsText();
                        list.add(s);
                    }
                    //setCurrentItem(0);
                }
            }
            else
            {
        System.err.println(getClass().getName()+".init(): indexedPropertyValue = null.");
            }
        }
        isInited = true;
    }

    private void setCurrentItem(int index)
    {
        if(index >= 0)
        {
            componentIndex = index;
            componentTypeEditor.setValue(Array.get(indexedPropertyValue, index));

            view.setEnabled(true);
            view.repaint();
            //view.requestFocus();
            list.deselect(list.getSelectedIndex());
            list.select(index);
            list.makeVisible(index);
            list.requestFocus();
        }
        else
        {
            view.setEnabled(false);
        }
    }

    public Dimension getPreferredSize()
    {
        return new Dimension(400, 280);
    }

    JButton b_newItem;
    List list;
    Component view;

}

Ответы (0 шт):