wood burning stoves 2.0*
The moose likes Java in General and the fly likes Customizing a JList with data variables. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Customizing a JList with data variables." Watch "Customizing a JList with data variables." New topic
Author

Customizing a JList with data variables.

Marvin Legend
Ranch Hand

Joined: Oct 18, 2013
Posts: 35
Hello my friends

I have a question, I would like that when I created a JList, I could put in it, the value of a text followed by the value of any variable, eg:

String name = "Anna";
int result = 17;

A print of the list would look like:



I would like to set the list what types of information will get into it, because these data will be captured variables.
Ramesh Pramuditha Rathnayake
Ranch Hand

Joined: Oct 31, 2012
Posts: 169
    
    1

You can put these two values to the list model by addElement(name +" " + result);
Or if you have a object of a model class, addElement(model.getName() +" " + model.getResult());


Ramesh-X
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

Ramesh Pramuditha Rathnayake wrote:You can put these two values to the list model by addElement(name +" " + result);
Or if you have a object of a model class, addElement(model.getName() +" " + model.getResult());

That's fine but just to ensure that the values never null.


http://muhammadkhojaye.blogspot.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Customizing a JList with data variables.
 
Similar Threads
JList + Vector
JList not refreshing ?issue?
JList transparent? Possibility to draw
Where do I put bus. logic for GUI class?
JList as a TableCellRenderer/TableCellEditor