int value = JOptionPane.showConfirmDialog (this, "新規作成する前に保存しますか?", "データーの保存", JOptionPane.YES_NO_CANCEL_OPTION); if (value == JOptionPane.YES_OPTION) { try{ FileOutputStream fo = new FileOutputStream( writefile() );//ストリームの作成 PrintStream ps = new PrintStream(fo);//ストリームの拡張 ps.println( text.getText() );//ファイルを書き込む ps.close();//psをクローズする fo.close();//foをクローズする text.setText (""); } catch( Exception x ) { System.out.println("I/O Exception"); } } else if (value == JOptionPane.NO_OPTION) { text.setText (""); } else if (value == JOptionPane.CANCEL_OPTION ){ } |
int value = JOptionPane.showConfirmDialog (this, "新規作成する前に保存しますか?", "データーの保存", JOptionPane.YES_NO_CANCEL_OPTION); |
if (value == JOptionPane.YES_OPTION) { try{ FileOutputStream fo = new FileOutputStream( writefile() );//ストリームの作成 PrintStream ps = new PrintStream(fo);//ストリームの拡張 ps.println( text.getText() );//ファイルを書き込む ps.close();//psをクローズする fo.close();//foをクローズする text.setText (""); } catch( Exception x ) { System.out.println("I/O Exception"); } } else if (value == JOptionPane.NO_OPTION) { text.setText (""); } else if (value == JOptionPane.CANCEL_OPTION ){ } |