jlist

How could I allow only unique strings in a JList ?

I have a JList that holds a bunch of strings . I would like it to act like a Set , so that it will only hold unique values . Is there any way to achieve this without checking that a new string doesn't already exist there ? ...

Swing JList binding questions

I have a JList which i want to use to display a list a caches that are added in from another form, I've got this working and I want to be able to add the caches directly to the list... Is there a way to change what gets displayed to the user? or would it simply be a case of making to the toString method of my object what i want to be dis...

Why do JList selections occur twice?

I have a JList with some items. I've added a listener for when a item in the list is selected. Here is the code for what happens when an item in the list is selected: private void questionaireNamesListValueChanged(javax.swing.event.ListSelectionEvent evt) { try { inputPa...

Java Swing - JList custom cell rendering - capturing actions

Any time I make a custom cell renderer for a JList, any elements I add to it don't ever respond to actions. For instance, If I have the cell renderer return a JPanel with elements on it, one of which has an ActionListener, it doesn't respond at all. Why is this? ...

JList select items with all mouse buttons

hello, how can i make a swing JList to have its items selected with any mousebutton not just the left one? thanks! ...

Is there a lazy loading implementation of JList ?

Hi, Is there a way to make a lazy loading with Swing JList ? Cheers, ...

Java problem: Need a sorted JList to represent a database table

I've found a sample for a sorted JList, but my application is powered by an embedded H2 database so I'm wondering if there isn't a better way to implement this with that in mind. Especially considering the table in question could become enormously large, and duplicating all that data in a JList's list model seems to kinda defeat the poi...

Sectioned List in Java/Swing?

I have a list of items in a JList for the user to select. Since it's a lot of items (say, cities in states), I want to divide the list into sections. The section headings should not be selectable, though. So for my cities/states example, this might look like this: State 1 City 1 City 2 City 3 State 2 City 4 City 5 City 6 It would...

Java updating JList using BeanBinding Netbeans

Hi, I have this JList (say MyList) in a JFrame. Im using Netbeans6 GUI builder and I've set a binding for this list. When run, the binding works fine, and MyList is populated correctly. Now, what im looking for is a way to add more data to this list from another text box on a button Click. But the problem exists here : W/o binding i ...

Adding Scrollbar to JList

I'm trying to add a scrollbar to a JList (which uses a custom data model). Adding a JScrollPane actually hides the JList, instead of adding a scrollbar. When I run the code with the scrollbar, the JList is not visible, and I cannot see the data. playlistField = new JList(playlist); // playlist is a data model playlistField.setLocation(3...

How can I add the keys of a LinkedHashMap to a JList?

I have a LinkedHashMap<String,Object> and was wondering what the most efficient way to put the String portion of each element in the LinkedHashMap into a JList. ...

Which is the better way to setListData in a jList, vector or array?

In this answer to a question I asked. Kathy Van Stone says that adding an array like so jList1.setListData(LinkedHashMap.keySet().toArray()); is a better way than to do it like this jList1.setListData(new Vector<String>(LinkedHashMap.keySet())); I am wondering if there was any truth to this and if so what the reason behind it was. ...

How can I get the text from a component in a JList?

I have a JList and I am wanting to get the text of an entry of that list at a specific index. Could someone inform me how to do this or should I restructure my code to getValues instead of getIndices? ...

How do I get a JList in netbeans to grab data from a vector in my model?

I'm a fairly experienced Java user, but I've just started trying to use NetBeans to build a GUI. Previously I coded GUIs by hand, but this is a bit of a bigger project. Anyways, I have a Vector in my model (MVC design), and I want to make the list populate with elements in my vector. I know how I'd do this by hand- I'd initiate the li...

How to generate a Jlist with alternating colors

In Java how do I get a JList with alternating colors? Any sample code? ...

Setting value in JList

Yes, setting value to a JList, know that. But i want to know is there an easy way to implement custom JList on which setSelectedValue() will not raise event to to inform attached listeners. I want to keep it quiet :). ...

Java Swing: JList with ListCellRenderer selected item different height

Hi all, I'm making a custom ListCellRenderer. I know that you can have different dimensions for each individual cell. But now I want to have a different dimension for the selected cell. Somehow, the JList is caching the dimension for each individual cell the first time it has to calculate bounds for each cell. This is my code: public c...

How to de-select a JList item from my program

I have a JList, and a JButton, user can click an item in the JList or they can click the button, when the button is clicked how do I de-select (change the selected list item bgcolor to normal, in other words, nothing in the JList will be selected after the button is clicked) the item from the JList ? ...

Java JList scroll to selected item

Hi, I have a jlist with a lot of items in it, of which one is selected. I would like to scroll to the selected item in this jlist, so the user can quickly see which item is selected. How can I do this? thanks! String[] data = {"one", "two", "three", "four", /* AND A LOT MORE */}; JList dataList = new JList(data); JScrollPane scrollPa...

How to change background color of the selected item in JList dynamically

How can I change the background color of the item which is selected in JList dynamically? ...