@FXML
void tampilComboMilik(MouseEvent event) {
String tmp = (String) cmb_milik.getSelectionModel().getSelectedItem();
String select_qry = "SELECT * FROM tbl_kepemilikan WHERE nama =?";
try {
pst = conn.prepareStatement(select_qry);
pst.setString(1, tmp);
rs = pst.executeQuery();
while(rs.next()){
String add1 = rs.getString("id_milik");
txt_warna.setText(add1);
}
rs.close();
pst.close();
}catch(Exception e){
System.out.println(e);
}
}
答案 0 :(得分:0)
您可以在fxml类中创建文本字段,并在initialize方法中将setVisible设置为False
像
@FXML
private String txt_warna;
@Override
public void initialize(URL url, ResourceBundle rb) {
txt_warna.setVisible(false);
}
现在,当您点击此方法并获取值时,将其显示为
@FXML
void tampilComboMilik(MouseEvent event) {
String tmp = (String) cmb_milik.getSelectionModel().getSelectedItem();
String select_qry = "SELECT * FROM tbl_kepemilikan WHERE nama =?";
try {
pst = conn.prepareStatement(select_qry);
pst.setString(1, tmp);
rs = pst.executeQuery();
while(rs.next()){
String add1 = rs.getString("id_milik");
txt_warna.setText(add1);
txt_warna.setVisible(true);
}
rs.close();
pst.close();
}catch(Exception e){
System.out.println(e);
}
}