Ok, I've found a working solution. It wasn't that hard as I expected:
val triggerSlopeListButton =
namespace.get("triggerSlope").asInstanceOf[ListButton]
val triggerData = new org.apache.pivot.collections.ArrayList[ListItem]
triggerData.add(new ListItem(new Picture(Oscilloscope.slopeRaisingIcon)))
triggerData.add(new ListItem(new Picture(Oscilloscope.slopeFallingIcon)))
triggerSlopeListButton.setListData(triggerData)
triggerSlopeListButton.setSelectedIndex(0)
val listViewItemRenderer = new ListViewItemRenderer
listViewItemRenderer.setShowIcon(true)
triggerSlopeListButton.setItemRenderer(listViewItemRenderer)
For sure, there should be an example of how to do that in the tutorial -
without looking at the Pivot source code I'd have no idea to use
something like ListItem. :(
BTW: How to set showIcon to true using BXML?
Regards,
Piotr
W dniu 2011-10-21 18:14, Piotr Kołaczkowski pisze:
Hello,
How to create a drop-down list with icons and text or icons only?
I tried this way:
val icon1 = ..... // some BufferedImage
val icon2 = ..... // some BufferedImage
val triggerSlopeListButton =
namespace.get("triggerSlope").asInstanceOf[ListButton]
val triggerData = new org.apache.pivot.collections.ArrayList[ButtonData]
triggerData.add(new ButtonData(new Picture(icon1)))
triggerData.add(new ButtonData(new Picture(icon2)))
triggerSlopeListButton.setListData(triggerData)
triggerSlopeListButton.setSelectedIndex(0)
It displays the icon correctly on the button when it is *not pressed*,
but when I press it, the expanded list contains
text like this:
org.apache.pivot.wtk.content.ButtonData@433598ca
org.apache.pivot.wtk.content.ButtonData@4545ab34
Why?
I want my icons there instead of text.
Regards,
Piotr
--
Piotr Kołaczkowski
senior consultant
Sages Sp. z o.o.
ul. Wąwozowa 11
02-796 Warszawa
t: +48 22 2035600
f: +48 22 2035601
m: +48 609618449