1 18 19 package org.apache.batik.swing.svg; 20 21 import java.awt.Component ; 22 import javax.swing.JDialog ; 23 import javax.swing.JOptionPane ; 24 import org.apache.batik.util.gui.JErrorPane; 25 26 35 public class SVGUserAgentGUIAdapter extends SVGUserAgentAdapter{ 36 public Component parentComponent; 37 public SVGUserAgentGUIAdapter(Component parentComponent) { 38 this.parentComponent = parentComponent; 39 } 40 41 44 public void displayError(String message) { 45 JOptionPane pane = new JOptionPane (message, JOptionPane.ERROR_MESSAGE); 46 JDialog dialog = pane.createDialog(parentComponent, "ERROR"); 47 dialog.setModal(false); 48 dialog.setVisible(true); 49 } 50 51 54 public void displayError(Exception ex) { 55 JErrorPane pane = new JErrorPane(ex, JOptionPane.ERROR_MESSAGE); 56 JDialog dialog = pane.createDialog(parentComponent, "ERROR"); 57 dialog.setModal(false); 58 dialog.setVisible(true); 59 } 60 61 65 public void displayMessage(String message) { 66 } 68 69 72 public void showAlert(String message) { 73 String str = "Script alert:\n" + message; 74 JOptionPane.showMessageDialog(parentComponent, str); 75 } 76 77 80 public String showPrompt(String message) { 81 String str = "Script prompt:\n" + message; 82 return JOptionPane.showInputDialog(parentComponent, str); 83 } 84 85 88 public String showPrompt(String message, String defaultValue) { 89 String str = "Script prompt:\n" + message; 90 return (String )JOptionPane.showInputDialog 91 (parentComponent, str, null, 92 JOptionPane.PLAIN_MESSAGE, 93 null, null, defaultValue); 94 } 95 96 99 public boolean showConfirm(String message) { 100 String str = "Script confirm:\n" + message; 101 return JOptionPane.showConfirmDialog 102 (parentComponent, str, 103 "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; 104 } 105 }; 106 | Popular Tags |