jlist

How to set the ListModel of a JList in Netbeans?

I have designed a Swing GUI with the help of Netbeans IDE and this GUI contains a JList. Bydefault, it uses AbstractListModel to pass it as an argument in the JList contructor to create that JList. I want to specify somewhere in the Netbeans to pass DefaultListModel as the model to be passed in that JList so that later I can retrieve i...

How to transfer the elements from one JList to other JList in Java?

I have two JList on a swing GUI. Now I want that when a user clicks on a button (say TransferButton) the selected elements from one JList is added from the first JList to the second JList and remove those selected elements from the first JList. ...

JScrollPane and JList auto scroll

Hi All, I've got the next code: listModel = new DefaultListModel(); listModel.addElement(dateFormat.format(new Date()) + ": Msg1"); messageList = new JList(listModel); messageList.setLayoutOrientation(JList.VERTICAL); messageScrollList = new JScrollPane(messageList); messageScrollList.setPreferredSize(new Dimen...

Java Swing JList

I am using a JList in Java Swing, but when my Dialog opens, the List isn't shown. private JList getJList() { if (mylist == null) { mylist = new JList(); mylist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mylist.setSize(new Dimension(154, 106)); model.addElement("test"); model.addElement("zwei"); mylist.set...

In Swing, is there a property to set a JList disabled foreground color?

In Swing, is there a property to set a JList disabled foreground color? I'm using the Netbeans GUI builder and I want to add a property to the resource properties file that sets the color of the text in a JList to a different default when the JList is disabled. Using the Nimbus LAF, there is a different color for this because the text ...

Saving MP3 playlist to file

Hello. I am making my own crude MP3 player, and I now have a JList with which I have populated a number of files in the form of MP3 objects (displayed on frame using DefaultListModel). I would now like to have the oppurtunity to save this JList to a file on disk. How would I go about doing this? I'm very new with programming and Java,...

Does a swing filterable JList component exist ?

For a specific screen, I'm looking for a JList that I could filter (the same way you can filter a JTable using a RowFilter) Is there a good implementation of this kind of component anywhere here in the wild (and do you have an experience with it) or do I have to code it myself ? (it is not that long to do, but if there is any valid imp...

JList with transparent cell renderer on MacOS

I have the following Java Swing code that shows a JList with custom cell renderer (JCheckBox used as renderer component). The JList itself is made transparent, and also the JCheckBox is made transparent, so basically the color of the background container (yellow) should shine through. This works fine on Windows and on Linux, but on MacO...

JList - deselect when clicking an already selected item

If a selected index on a JList is clicked, I want it to de-select. In other words, clicking on the indices actually toggles their selection. Didn't look like this was supported, so I tried list.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { java.awt.Point point = evt.getPoint(); int in...

Did Hans Muller ever publish "Mastering JList Programming" as promised?

This article was Part 1 of a two part article. I cannot find Part 2, "Mastering JList Programming". Google cannot find it. Did it get lost in the Oracle-Sun move, or was it never published? ...

jList in Scrollpane, seeking and displaying value of selectedIndex

I have a JList inside a Scrollpane. If you click on the list and move the arrow keys up and down it works like you expect, you can move your selection index and display around just fine. Now, what I want to do is basically have a text box and i'm typing in the text box like "comic" and want it to seek to the index of that value. This ...

scroll/search JList when user starts typing

I would like to implement one of the fanciest features I every now and then. I would like to allow a user to click on a JList and if words are typed, do a query and advance the caret to the next match (prefix). Is there and example of such an implementation in Java somewhere? I'm thinking a combination of key listeners, getNextMatch() an...

How would I go about highlighting an item in a JList?

I have a JList and I want to be able to highlight (change colour of text or something similar) the selected item. I know there are methods to set which item is selected but can I change the color of the text of that item etc? ...

searching the strings using starting characters in Jlist?

I am creating a search list in java. If I enter the beginning letters, then the corresponding words which belongs to the letters will be display on the Jlist.For that is there any build in methods is there? Then how can i search the words with starting characters? Suggest me. Thank in advance.. ...

Putting sql result set into JList

Hi there. I'm working on my second year project and I'm nearly finished, but I've got a problem. I have a table set up in Oracle that holds user names, recipients, and messages. I wanted to make a contacts list for sending messages that would take the user names and put them into a swing jlist but i cant figure out how. I thought m...

Passing array into constructor to use on JList

I know the title sound confusing and thats because it is. its a bit long so try too stay with me. this is the layout i have my code designed variables constructor methods. im trying too fill a Jlist full on names. i want too get those names using a method. so here goes. in my variables i have my JList. its called contactNames; i also...

Array not showing in Jlist but filled in console

Hey there. been a busy debugger today. ill give ths short version. ive made an array list that takes names from a database. then i put the contents of the arraylist into an array of strings. now i want too display the arrays contents in a JList. the weird thing is it was working earlier. and ive two methods. ones just a little practi...

java Swing Listeners: components listening at each others.

Hi all, I want to code two JList (categories and items). When I click one category it should select all the items for that category and when I click on one item it should select its categories. So both JList will have a ListSelectionListener listening at each other and changing the selection. Should I fear about some a of "loop" ? Is th...

JList with JScrollPane and prototype cell value wraps element names (replaces with dots instead of showing horizontal scrollbar), why?

I've got a Jlist inside a JScrollPane and I've set a prototype value so that it doesn't have to calculate the width for big lists, but just uses this default width. Now, the problem is that the Jlist is for some reason replacing the end of an element with dots (...) so that a horizontal scrollbar will never be shown. How do I disable w...

How to get multiline for a Jlist text?

I have a problem in get mutiline for Jlist ! Do you have any idiea? ...