public static ComponentUI createUI(JComponent c){
  if (c == null || sliderClass == null) {
    return null;
  }
  UIDefaults defaults=UIManager.getLookAndFeelDefaults();
  try {
    Method m=(Method)defaults.get(sliderClass);
    if (m == null) {
      m=sliderClass.getMethod("createUI",new Class<?>[]{JComponent.class});
      defaults.put(sliderClass,m);
    }
    ComponentUI uiObject=(ComponentUI)m.invoke(null,new Object[]{c});
    if (uiObject instanceof BasicSliderUI) {
      c.addHierarchyListener(new MouseAttacher());
    }
    return uiObject;
  }
 catch (  NoSuchMethodException|SecurityException|IllegalAccessException|IllegalArgumentException|InvocationTargetException e) {
    throw new RuntimeException(e);
  }
}

public static ComponentUI createUI ( JComponent c ) { if ( c == null || sliderClass == null ) { return null ; } UIDefaults defaults = UIManager . getLookAndFeelDefaults ( ) ; try { Method m = ( Method ) defaults . get ( sliderClass ) ; if ( m == null ) { m = sliderClass . getMethod ( "createUI" , new Class < ? > [ ] { JComponent . class } ) ; defaults . put ( sliderClass , m ) ; } ComponentUI uiObject = ( ComponentUI ) m . invoke ( null , new Object [ ] { c } ) ; if ( uiObject instanceof BasicSliderUI ) { c . addHierarchyListener ( new MouseAttacher ( ) ) ; } return uiObject ; } catch ( NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) { throw new RuntimeException ( e ) ; } }
returns the ui as normal , but intercepts the call , so that a listener can be attached
