Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Items in a JList be formatted as HTML

Tags:

java

html

jlist

I would like to create a JList in Java so that each individual item is formattted using HTML tags, but I'm not clear how to do this or even if this is possible. Does anyone have any suggestions?

Thank you.

like image 878
Elliott Avatar asked Jun 18 '10 14:06

Elliott


People also ask

How get values from JList?

We can display a value when an item is selected from a JList by implementing MouseListener interface or extending MouseAdapter class and call the getClickCount() method with single-click event (getClickCount() == 1) of MouseEvent class.

What is the purpose of JList?

JList is a component that displays a set of Objects and allows the user to select one or more items . JList inherits JComponent class. JList is a easy way to display an array of Vectors .

Which interface is implemented in JList?

Simple, dynamic-content, JList applications can use the DefaultListModel class to maintain list elements. This class implements the ListModel interface and also provides a java.


1 Answers

Its actually very simple. For every string in the list surround it with the html tags such as this:

<html><font color=green>this will be green</font></html>

When the JList displays it it will be green.

like image 147
Mike Avatar answered Sep 28 '22 09:09

Mike