Skip to main content

Changing ComboBox.items works ...sometimes? (Bug?)

3 replies [Last post]
newcron
Offline
Joined: 2008-01-14

Hello, I'm experiencing some strange behaviour of a ComboBox here.

I'm trying to change the contents of a ComboBox after it has been created and placed on screen. This is done in a callback, when results form an asynchronous Web Query arrive.

To change the contents, I tried:

delete comboBox.items;
insert newContents into comboBox.items

aswell as

comboBox.items = newContents;

As mentioned earlier, this does work sometimes.
Calling

java.lang.System.out.println("in Box: {comboBox.items} should be: {newContents}");
directly afterwards will either result in an empty list for comboBox.items or in the correct list.

Does anybody have an idea, what's going on here?

PS: I also tried to updateUI or repaint the comboBox or it's parent, which has no effect.

Message was edited by: newcron

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
newcron
Offline
Joined: 2008-01-14

Hello!

Thanks for your responses. I was in the wrong thread.

kram
Offline
Joined: 2007-10-23

Is the contents of the combo bound to the sequence? I.e. using the 'bind' keyword?

the following code works ok for me:

[code]

import javafx.application.*;
import javafx.ext.swing.*;
import javafx.animation.*;

var items:ComboBoxItem[] = [
ComboBoxItem {
text: "One"
selected: true
},
ComboBoxItem {
text: "Two"
}
];

var box1:ComboBox = ComboBox {
items: bind items
x:200; y:200; width: 200; height: 50;

}
Timeline {
repeatCount: Timeline.INDEFINITE
keyFrames : [
KeyFrame {
time : 2s
action: function(){
insert ComboBoxItem{ text: "New" } into items;
}
}
]
}.start();

SwingFrame {
title: "Sample App"
width: 500
height: 500
closeAction: function() {
java.lang.System.exit( 0 );
}
visible: true

menus: [ ]

content: Panel {
content: [
box1
]
}
}
[/code]

Added code

Message was edited by: kram

Message was edited by: kram

michael_heinrichs
Offline
Joined: 2007-11-15

Have you made sure, that you are changing the values on the right thread?