3
3
3ema2019-12-03 16:59:46
Java
3ema, 2019-12-03 16:59:46

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 5de66a040cc99483056388.jpeg5de66a0b50f17899803904.jpeg5de66a12a7eb7262531973.jpeg5de66a18339f1573020137.jpeg)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
striver, 2020-12-30
@striver

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.

Method for displaying data in TableView depending on the data in the combobox
public void orderByAreaOnline() {
        if (cbSetAreaOnline.getSelectionModel().getSelectedItem().toString().equals("-")) {
            clearAreaOnlineNoDateWithAreaCB();
            loadTableViewAreaOnline(obListAreaOnline, connToKZ, tableAreaOnline);
        } else {
            refreshJournalOnLineSelectArea(obListAreaOnline, TABLE_JOURNAL, tableAreaOnline, connToKZ, pst, rs, cbSetAreaOnline);
        }
    }

clearAreaOnlineNoDateWithAreaCB - nothing like that, just clearing text fields from unnecessary data.
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 question

Ask a Question

731 491 924 answers to any question