1 package org.enhydra.shark.swingclient; 2 3 import java.util.*; 4 import java.awt.*; 5 6 9 public class Utils { 10 11 17 public static String [] tokenize(String input,String boundary) { 18 if (input==null) input=""; 19 Vector v = new Vector(); 20 StringTokenizer t = new StringTokenizer(input,boundary); 21 String cmd[]; 22 23 while (t.hasMoreTokens()) 24 v.addElement(t.nextToken()); 25 cmd = new String [v.size()]; 26 for (int i = 0; i < cmd.length; i++) 27 cmd[i] = (String )v.elementAt(i); 28 29 return cmd; 30 } 31 32 33 public static String getUnqualifiedClassName (Class cls) { 34 String name=cls.getName(); 35 int lastDot=name.lastIndexOf("."); 36 if (lastDot>=0) { 37 name=name.substring(lastDot+1,name.length()); 38 } 39 return name; 40 } 41 42 public static void center (Window w) { 43 Rectangle screenSize = GraphicsEnvironment 46 .getLocalGraphicsEnvironment() 47 .getDefaultScreenDevice() 48 .getDefaultConfiguration() 49 .getBounds(); 50 51 int width=w.getWidth(); 52 int height=w.getHeight(); 53 if (width>screenSize.width-50) { 54 width=screenSize.width-50; 55 } 56 if (height>screenSize.height-100) { 57 height=screenSize.height-100; 58 } 59 w.setBounds((screenSize.width-width)/2,(screenSize.height-height)/2, 60 width,height); 61 } 62 } 63 | Popular Tags |