をするJava Swingを使っ:
dialog.setVisible(true);
// blocked here until the dialog is closed. The dialog stores the input in a
// field when OK is clicked in the dialog
if (dialog.getTextInputtedByTheUser() != null) {
...
ダイアログの場合モーダルではない場合は、検証が行われたときにコールバックメソッドを呼び出さなければなりません。これはMyFrameとは
private void showDialog(
MyDialog dialog = new MyDialog(this);
dialog.setVisible(true);
}
public void userHasInputSomeText(String text) {
// do whatever you want with the text
System.out.println("User has entered this text in the dialog: " + text);
}
とMyDialogにが含まれているだろうかです:
あなたがテキストボックスのためのactionPerformed(のActionEvent AE)を使用することはできませんなぜ
private MyFrame frame;
public MyDialog(MyFrame frame) {
super(frame);
this.frame = frame;
}
...
private void okButtonClicked() {
String text = textField.getText();
frame.userHasInputSomeText(text);
}
ClassAに値が変更されていることを監視して知らせますか? –
ユーザーが変数を更新するために[OK]ボタンをクリックしたときにクラスBの変数を更新しているときに使用します – user913059