Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Customizing a JList with data variables.

 
Marvin Legend
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 178
2
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic