static Method getMethod (Class cls, String name, Object[] args) {
        Class[] args_cls = new Class[args.length];
        for (int i = 0; i < args.length; i++) {
            if (args[i] instanceof Boolean) {
                args_cls[i] = Boolean.TYPE;
            }
            else if (args[i] instanceof Character) {
                args_cls[i] = Character.TYPE;
            }
            else if (args[i] instanceof Integer) {
                args_cls[i] = Integer.TYPE;
            }
            else if (args[i] instanceof Double) {
                args_cls[i] = Double.TYPE;
            }
            else if (args[i] instanceof Float) {
                args_cls[i] = Float.TYPE;
            }
            else if (args[i] instanceof GraphicsConfiguration) {
                // hack to make subclasses of GraphicsConfiguration work
                args_cls[i] = GraphicsConfiguration.class;
            }
            else {
                args_cls[i] = args[i].getClass();
            }
        }
        try {
            return cls.getMethod(name, args_cls);
        }
        catch (NoSuchMethodException ex) {
            return null;
        }
    }