动态更新实时事件的文本字段



我目前正在开发一个带有javafx的Softphone。 而且我在捕获对文本字段的传入调用时遇到了问题。 我的代码示例在这里。 来电是 Joptionpane 成功 BT 我希望让值出现在呼叫文本字段中,就像电话一样。 谢谢。

public void telephoneNumbs(String numbers) {
String replace = numbers.replace("sip:", "").trim().replace(".", ""); // Incoming Call Numbers from Sip UA
if (!replace.isEmpty()) {
List<TelephoneObj> telephons; 
telTextField.setText(null); //init it with null
costumDao = new CostumersDao(); // costumers DB 
telephons = costumDao.getOrCompareTelfone(numbers);
for (TelephoneObj tmp : telephons) {
System.out.println("Test: " + tmp.getTelephoneNums); // am getting exactle what i need here from my Database
//or 
JOptionPane.showMessageDialog(null,"incoming:"+ tmp.getTelephoneNums); // it show it during incoming calls
//here is the problem. it wouldnt show the Value on the Textfield
telTextField.setText(tmp.getTelephoneNums); //try to push that Value(Telephone number) to show in JFXTextfield/it cold be any other Textfields
}

}

今天非常高兴,经过两天的思考,如何解决这种没有时间思考的悲惨生活,它进展顺利。 我终于通过使用任务来解决问题得到了答案。

Task<Void> task = new Task<Void>() {
{
updateMessage("");
}
@Override
public Void call() throws Exception {
while (true) {
updateMessage(callee);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
break;
}
}
return null;
}
};
//neuLabel.textProperty().bind(task.messageProperty());
kdAddrTel.textProperty().bind(task.messageProperty());
Thread th = new Thread(task);
th.setDaemon(true);
th.start();

最新更新