1 package org.apidesign.exceptions.trycatchredo.usage;
3 import java.awt.EventQueue;
4 import java.awt.event.ActionEvent;
6 import javax.swing.Action;
7 import org.apidesign.exceptions.trycatchredo.api.IOManager;
8 import org.apidesign.exceptions.trycatchredo.api.UserQuestionException;
10 /** Sample usage showing interactive storage capabilities of the
11 * {@link UserQuestionException}
13 * @author Jaroslav Tulach <jtulach@netbeans.org>
16 public static void main(String[] args) throws Exception {
17 MemoryURL.initialize();
19 for (int cnt = 0; cnt < 10; cnt++) {
20 URL u = new URL("memory://" + cnt + "/queryEncoding.txt");
21 MemoryURL.registerURL(u.toExternalForm(), "", new QueryStream());
22 final Action a = IOManager.createSaveAction(u, "Ask a Question");
23 EventQueue.invokeAndWait(new Runnable() {
25 a.actionPerformed(new ActionEvent(this, 0, ""));
28 String out = MemoryURL.getOutputForURL(u.toExternalForm());
30 System.err.println(cnt + " output: " + out);