| 1 package sellwin.gui; 2 3 import java.util.*; 4 import java.awt.*; 5 import javax.swing.*; 6 import javax.naming.*; 7 import javax.ejb.*; 8 9 13 17 public class Utility { 18 23 public static void strSet(JTextArea f, String from) { 24 if (from != null) { 25 f.setText(from); 26 f.setCaretPosition(0); 27 } 28 else 29 f.setText(""); 30 } 31 36 public static void strSet(JTextField f, String from) { 37 if (from != null) { 38 f.setText(from); 39 f.setCaretPosition(0); 40 } 41 else 42 f.setText(""); 43 } 44 50 public static void comboSet(JComboBox b, Object item) { 51 if (item != null) 52 b.setSelectedItem(item); 53 else 54 b.setSelectedIndex(0); 55 } 56 57 62 public static void setLang(Container container) { 63 Component[] components = container.getComponents(); 64 Component c; 65 66 for (int i=0;i<components.length;i++) { 67 c = components[i]; 68 if (c instanceof Container) { 69 Utility.setLang((Container)c); 70 } 71 72 if (c instanceof GUIChars) { 73 ((GUIChars)c).setLang(); 74 } 75 76 if (c instanceof JDialog) { 77 if (c instanceof GUIChars) 78 ((GUIChars)c).setLang(); 79 else 80 Utility.setLang((Container)c); 81 82 } 83 84 } 85 } 86 87 public static InitialContext getEJBContext(String host, String port) 88 throws NamingException { 89 90 Hashtable props = new Hashtable(); 91 props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); 92 props.put("java.naming.provider.url","jnp://"+host+":"+port); 93 props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); 94 95 InitialContext ic = new InitialContext(props); 96 return ic; 97 } 98 } 99 | Popular Tags |