0

我想向 Jlist 显示列表播放器,但它没有显示所有列表,最后只显示 2 个元素。这是我的代码:

           //create List player

    listplayersource = new DefaultListModel();
    listplayersource.addElement("VIP player 1");        
    list_player = new JList(listplayersource);
    list_player.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list_player.setLayoutOrientation(JList.VERTICAL);
    list_player.setVisibleRowCount(16);     
    panelmain.add(new JScrollPane(list_player), BorderLayout.WEST);

    listplayersource.addElement("Vip player 2");

    listplayersource.addElement("VIP player 2");
    listplayersource.addElement("VIP player 3");
    listplayersource.addElement("VIP player 4");
    listplayersource.addElement("VIP player 5");

结果:

      VIP player 4

      VIp player 5

它有什么问题? 在此处输入图像描述

4

0 回答 0