Answer the question
In order to leave comments, you need to log in
How to access combobox' from another class?
When a user logs in, he selects his category in the combobox, and when I open orders, I want orders that belong to that combobox to be displayed. So, how to refer to the combobox (cbnameofservice in the FXMLzakazuserController.java class) which is in another class (UserjoinController.java )?
Answer the question
In order to leave comments, you need to log in
My implementation goes through SkinBuilder. So I'll let you know the way I do. On the combo box, I select On Action, the predefined method for loading the plate, depending on the data from the combo box.
public void orderByAreaOnline() {
if (cbSetAreaOnline.getSelectionModel().getSelectedItem().toString().equals("-")) {
clearAreaOnlineNoDateWithAreaCB();
loadTableViewAreaOnline(obListAreaOnline, connToKZ, tableAreaOnline);
} else {
refreshJournalOnLineSelectArea(obListAreaOnline, TABLE_JOURNAL, tableAreaOnline, connToKZ, pst, rs, cbSetAreaOnline);
}
}
private void loadTableViewAreaOnline(ObservableList oblist, Connection conn, TableView table) {
oblist.clear();
try {
String sql = "SELECT journal.idauto, "
+ "journal.dateAreaOut, "
+ "journal.areaTimeOut, "
+ "journal.number, "
+ "journal.mark, "
+ "journal.model, "
+ "journal.driver, "
+ "journal.mileageOut, "
+ "journal.mechMileageOut, "
+ "journal.fuelMainOut, "
+ "journal.fuelAddOut, "
+ "journal.fuelMechOut, "
+ "journal.areaOut, "
+ "journal.vehicleID, "
+ "vehicleList.fuelNorm "
+ "FROM journal join vehicleList on journal.vehicleID = vehicleList.vehicleId "
+ "where journal.status = '" + VEH_STATUS_ONLINE + "' "
+ "ORDER by journal.dateAreaOut, journal.areaTimeOut";
pst = conn.prepareStatement(sql);
pst.setQueryTimeout(40000);
rs = pst.executeQuery();
while (rs.next()) {
oblist.add(new ModelTableOnline(
rs.getString("idauto"),
rs.getString("dateAreaOut"),
rs.getString("areaTimeOut"),
rs.getString("number"),
rs.getString("mark"),
//
rs.getString("model"),
rs.getString("driver"),
rs.getString("mileageOut"),
rs.getString("mechMileageOut"),
rs.getString("fuelMainOut"),
rs.getString("fuelAddOut"),
rs.getString("fuelMechOut"),
rs.getString("areaOut"),
rs.getString("vehicleID"),
rs.getString("fuelNorm")
));
}
table.setItems(oblist);
} catch (SQLException ex) {
Logger.getLogger(TableController.class.getName()).log(Level.SEVERE, null, ex);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question