GWT listbox text color, selection

1,472 views
Skip to first unread message

kevinSC

unread,
Jun 11, 2008, 12:03:06 PM6/11/08
to Google Web Toolkit
is there a way to change the text color of individual elements in a
listbox? also, is there a way to set an element in the listbox NOT
selectable?

mbracken

unread,
Jun 11, 2008, 1:14:29 PM6/11/08
to Google Web Toolkit
the listbox doesn't provide the level of detail to change the style on
an individual element or to make individual items unselectable. you
can set a style for the selected item.

it sounds like you'll need to extend the listbox and add your own
functionality to accomplish what you're trying to do.

jhulford

unread,
Jun 12, 2008, 9:28:26 AM6/12/08
to Google Web Toolkit
You CAN set styles on individual option elements and it works fine in
Firefox and, I think, most other browsers except IE6.

mbracken

unread,
Jun 12, 2008, 3:27:03 PM6/12/08
to Google Web Toolkit
how do you set the styles on individual elements?
> > > selectable?- Hide quoted text -
>
> - Show quoted text -

Nicholas DiMucci

unread,
Jan 22, 2013, 11:02:50 AM1/22/13
to google-we...@googlegroups.com, Google Web Toolkit, levi.b...@gmail.com
Actually figured out the solution I was looking for. 

This will iterate through all of the items in a ListBox, changing the items font color to red. 

ListBox listBox = new ListBox();
// Assuming a bunch of items were added to listBox....
SelectElement selectElement = SelectElement.as(listBox.getElement());
NodeList<OptionElement> options = selectElement.getOptions();

for (int i = 0; i < options.getLength(); i++) {
     options.getItem(i).getStyle().setColor("#FF0000");
}
 

On Tuesday, January 22, 2013 1:03:01 AM UTC-5, Faith wrote:
It can be changed using listBox.setStyleName();

On Friday, January 18, 2013 6:55:22 PM UTC+5:30, Nicholas DiMucci wrote:
*blows cobwebs off this thread*

Can anyone answer this question? I'm looking to change the font color of individual items within a ListBox.
Reply all
Reply to author
Forward
0 new messages