Hello, I'm currently creating a PlayList for a media application I am working on. I'm using a JList as the GUI object for the PlayList and a DefaultListModel as the storage area to be held in the PlayList. I was hoping that if I was to pass a DefaultListModel object containing no information I could create a JList that had, lets say, 5 rows visible how that doesn't seem to be the case. Overall I'm hoping that I can have the playlist (JList) stay the same size whether their is data in the DefaultListModel or if it is completely empty (like a new playlist. Basically the playlist would sort of work like Winamp's. Below is some of the code I'm using:

playListPanel=new JPanel();
		playListPanel.setBorder(new TitledBorder("PlayList"));
		playListData=new DefaultListModel();
		playListDisplay=new JList();
		playListDisplay.setModel(playListData);
		playListDisplay.setFixedCellWidth(300);
		playListDisplay.setVisibleRowCount(5);
		playListDisplay.setDragEnabled(true);

		playListData.addElement("");
		//playListDisplay.setListData(playListData);
		scrollPane = new JScrollPane(playListDisplay,
						ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
						ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		playListPanel.add(scrollPane);

Thanks in advance for the help

Recommended Answers

All 2 Replies

Overall I'm hoping that I can have the playlist (JList) stay the same size whether their is data in the DefaultListModel or if it is completely empty

When you say size, are you referring to the visual aspect of the component? Cause having the size of a list with 5 elements when its empty doesn't make sense to me.

Yeah I know I didn't make any sense, I figured out my problem though; sorry for the troubles.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.