| author | Jaroslav Tulach <jtulach@netbeans.org> |
| Fri Aug 27 14:06:39 2010 +0200 | |
| changeset 365 | 0b7ec6ef8a72 |
| parent 312 | 0678c9589013 |
| permissions | -rw-r--r-- |
| jtulach@312 | 1 |
package org.apidesign.exceptions.trycatchredo.api; |
| jtulach@312 | 2 |
|
| jtulach@312 | 3 |
import java.awt.EventQueue; |
| jtulach@312 | 4 |
import java.awt.event.ActionEvent; |
| jtulach@312 | 5 |
import java.io.IOException; |
| jtulach@312 | 6 |
import java.io.OutputStream; |
| jtulach@312 | 7 |
import java.net.URL; |
| jtulach@312 | 8 |
import javax.swing.AbstractAction; |
| jtulach@312 | 9 |
import javax.swing.JOptionPane; |
| jtulach@312 | 10 |
|
| jtulach@312 | 11 |
/** |
| jtulach@312 | 12 |
* |
| jtulach@312 | 13 |
* @author Jaroslav Tulach |
| jtulach@312 | 14 |
*/ |
| jtulach@312 | 15 |
final class SaveAction extends AbstractAction {
|
| jtulach@312 | 16 |
private final URL where; |
| jtulach@312 | 17 |
private final CharSequence what; |
| jtulach@312 | 18 |
|
| jtulach@312 | 19 |
SaveAction(URL where, CharSequence what) {
|
| jtulach@312 | 20 |
this.where = where; |
| jtulach@312 | 21 |
this.what = what; |
| jtulach@312 | 22 |
} |
| jtulach@312 | 23 |
|
| jtulach@312 | 24 |
|
| jtulach@312 | 25 |
public void actionPerformed(ActionEvent ev) {
|
| jtulach@312 | 26 |
assert EventQueue.isDispatchThread(); |
| jtulach@314 | 27 |
// BEGIN: trycatchredo.SaveAction |
| jtulach@312 | 28 |
try {
|
| jtulach@312 | 29 |
OutputStream os = where.openConnection().getOutputStream(); |
| jtulach@312 | 30 |
os.write(what.toString().getBytes()); |
| jtulach@312 | 31 |
os.close(); |
| jtulach@312 | 32 |
} catch (IOException ex) {
|
| jtulach@312 | 33 |
JOptionPane.showMessageDialog(null, ex); |
| jtulach@312 | 34 |
} |
| jtulach@314 | 35 |
// END: trycatchredo.SaveAction |
| jtulach@312 | 36 |
} |
| jtulach@312 | 37 |
} |