1 19 package org.lucane.client.widgets; 20 21 import java.util.Vector ; 22 import javax.swing.*; 23 import javax.swing.JOptionPane ; 24 25 import org.lucane.client.util.Translation; 26 import org.lucane.common.Logging; 27 28 29 public class DialogBox 30 { 31 36 public static void error(String message) 37 { 38 JOptionPane.showMessageDialog(null, message, "Lucane", JOptionPane.ERROR_MESSAGE); 39 Logging.getLogger().info(message); 40 } 41 42 47 public static void info(String message) 48 { 49 JOptionPane.showMessageDialog(null, message, "Lucane", JOptionPane.INFORMATION_MESSAGE); 50 Logging.getLogger().info(message); 51 } 52 53 60 public static boolean question(String title, String message) 61 { 62 Object [] options = {Translation.tr("yes"), Translation.tr("no")}; 63 int response = JOptionPane.showOptionDialog( 64 null, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, 65 null, options, options[0]); 69 if(response == JOptionPane.YES_OPTION) 70 return true; 71 else 72 return false; 73 } 74 75 82 public static String input(String title, String message) 83 { 84 return JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE); 85 } 86 87 95 public static String input(String title, String message, String defaultValue) 96 { 97 return (String )JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE, null, null, defaultValue); 98 } 99 100 109 public static int list(JFrame owner, String title, String message, Vector list) 110 { 111 return (new ListBox(owner, title, message, list)).selectItemByIndex(); 112 } 113 } 114 | Popular Tags |