Jfoenix: How to change the value of Combo box when reading data from DB

Created on 2 May 2017  路  8Comments  路  Source: sshahine/JFoenix

How to change the value of combo box when calling a record from db. where in nomal SWING Java i use this code
cmbType.setSelectedItem(model.getValueAt(i, 2).toString());

How to do it on JFX Combo box please help!

Thanks in advance!

Most helpful comment

Hello,
you need to use JFXComboBox<String> instead of JFXComboBox<Label>, or select the actual node from the items list instead of creating a new node for the selected item.

Regards,

All 8 comments

Well i tried these but it didnt work. What im doing is getting the values from db and setting it on combo box. Like bringing up one record and pushing it inside the text and combo. Text comes right but not combo. When i use the methods in the above links the combo will show blank.

Code i used
cmbType.getSelectionModel().select(new Label(rs.getString("Type")));
cmbType.setValue(new Label(rs.getString("Type")));

Hello,
you need to use JFXComboBox<String> instead of JFXComboBox<Label>, or select the actual node from the items list instead of creating a new node for the selected item.

Regards,

hello admin,

didnt get you here

you need to use JFXComboBox instead of JFXComboBox

sorry the tags got ignored and treated as html tags instead of code.

how can i do that node selection im really sorry for asking dumb questions like this but im a noob here thats why

Hey admin,

It did worked. But now im back to a ealier prob which to make the text white. I used -fx-text-fill: WHITE; but didnt work still black. Can you help me? Thank you very very much.

Found it sorry for bothering :)

this is the code if anyone else needs it in future..

.jfx-combo-box { -fx-background-color: #263146; -fx-text-fill: WHITE; } .jfx-combo-box .cell:selected{ -fx-background-color: #263146; -fx-text-fill: WHITE; }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

imgx64 picture imgx64  路  5Comments

riftshadow picture riftshadow  路  4Comments

MikeChav picture MikeChav  路  3Comments

salwyn picture salwyn  路  3Comments

orochies picture orochies  路  5Comments