import java.awt.*;
import javax.swing.*;
/**
* ClosedOperationDialog クラスは、更新中のファイルの扱いを確認する際に使用するダイアログを提供します。
*/
public class ClosedOperationDialog extends JOptionPane{
private String message;
/**
* 警告アイコンと、「はい」「いいえ」「キャンセル」ボタンを持つダイアログを生成します。
*/
public ClosedOperationDialog(){
super(new String(""));
String lineSeparator=System.getProperty("line.separator");
message=new String("ファイルの内容は変更されています。" +
lineSeparator +
"変更を保存しますか?");
}
/**
* 更新中のファイルの扱いを確認するダイアログを表示します。
* @param parent 親コンポーネント
* @param title ダイアログのタイトル
* @return ダイアログを操作した後の結果コード
*/
public int showClosedDialog(Component parent,String title){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception exc){
System.err.println("Error loading L&F: " + exc);
}
return super.showConfirmDialog(parent,message,title,YES_NO_CANCEL_OPTION,WARNING_MESSAGE);
}
}