Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thinlet Question

 
Sundar Ram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Iam using Thinlet in my project. Iam using list(A list allows the user to select one or more objects from a list). Iam creating an empty list initially, and adding items to the list dynamically. So i wanted to colour each list item dynamically at runtime. Each list item needs to have a different color depending on certain conditions. So, how to clolor each item in a list dynamically??

Kindly help,

-Sundar
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sundar-

Welcome to JavaRanch.

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it; specifically, a first name and a last name are required. Please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.

As to your question, AWT itself does not support this (and neither does Swing), so Thinlet can't add that behavior.
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All you have to do is write a ListCellRenderer that does the coloring you need. There's information in the JList API Doc and the Java Tutorial Swing trail
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I stand corrected regarding Swing. But Thinlet uses AWT, so it's still not going to work.
 
Sundar Ram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Hello Sundar-

Welcome to JavaRanch.

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it; specifically, a first name and a last name are required. Please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.

As to your question, AWT itself does not support this (and neither does Swing), so Thinlet can't add that behavior.


Hello Ulf Dittmer,
I was not aware of the javaranch naming policy before. Thanks for prompting me. Now ive changed it. And also thanks for the reply.
 
Sundar Ram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer,

We can change the list items color in thinlet. But it has to be specified in the XUL file(foreground attribute of item element) which we create for the interface. But this should be done at design time i.e when we write the code. But i require to change the foreground/background color dynamically at runtime.

-Sundar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic