現在、JavaFxを使用してデータベースを検索するソフトウェアモジュールを作成しています。 すべてが期待どおりに機能しています。 しかし、唯一の問題は、私の結果の表では、検索の詳細がほんの少ししか表示されていないことです(UXの問題から:詳細が多く、長いテキストがあります)。 私がしたいのは、TextFieldsとTextAreaのクリックされた行のすべての詳細を含む新しいウィンドウを表示することです。 私はいくつかのチュートリアルと回答を見ましたが、残念ながら何も動作していません。 ご協力いただければ幸いです! ありがとうございます。新しいウィンドウで検索結果(JavaFx)
SearchResult.setOnMouseClicked(new EventHandler<MouseEvent>() {
Gemo temp;
@Override
public void handle(MouseEvent event) {
Gemo row = SearchResult.getSelectionModel().getSelectedItem();
if(row == null) {
System.out.print("I am not in");
return ;
}
else {
temp = row;
String id = String.format(temp.getRef());
System.out.println(id);
FXMLLoader loader=new FXMLLoader();
loader.setLocation(getClass().getResource("DetailsWindow.fxml"));
ControllerDetails gemodetails=loader.getController();
ControllerDetails gd=new ControllerDetails();
gd.SearchById(id);
try{
loader.load();
} catch (IOException e) {
e.printStackTrace();
}
Parent p= loader.getRoot();
Stage stage=new Stage();
stage.setTitle("More Details");
stage.setScene(new Scene(p));
stage.show();
}
}
});
public class ControllerDetails {
@FXML
private TextField fn_patient;
@FXML
private TextField ln_patient;
@FXML
private TextField db_patient;
@FXML
private TextField id_patient;
@FXML
private TextField id_visit;
@FXML
private TextField date_visit;
@FXML
private TextField fn_user;
@FXML
private TextField ln_user;
@FXML
private TextField status;
@FXML
private TextArea com;
@FXML
public void initialize(){
}
public void SearchById(String id) {
Connection connection = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
connection = ConnectionConfiguration.getConnection();
statement = connection.prepareStatement("my_sql_query");
rs = statement.executeQuery();
while (rs.next()) {
id_visit.setText(rs.getString(1));
id_patient.setText(rs.getString(2));
date_visit.setText(rs.getString(3));
com.setText(rs.getString(4));
fn_patient.setText(rs.getString(5));
ln_patient.setText(rs.getString(6));
db_patient.setText(rs.getString(7));
fn_user.setText(rs.getString(8));
ln_user.setText(rs.getString(9));
status.setText(rs.getString(10));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
あなたの質問にもっと力を入れる必要があります。これまでに行ったこと、ログ、コードなどを表示してください。https://stackoverflow.com/help/how-to-ask – Rolo
https://stackoverflow.com/に記載されているテクニックの1つを使ってみませんか?質問/ 14187963/passing-parameters-javafx-fxml? –