1 19 20 package org.netbeans.modules.tasklist.timerwin; 21 22 import java.awt.Window ; 23 import java.lang.reflect.Method ; 24 import javax.swing.JDialog ; 25 26 31 public class AlwaysOnTop { 32 private static boolean libLoaded; 33 private static Method setAlwaysOnTopMethod; 34 35 static { 36 try { 37 setAlwaysOnTopMethod = Window .class.getDeclaredMethod( 38 "setAlwaysOnTop", new Class [] {Boolean.TYPE}); 40 } catch (Throwable t) { 41 } 43 44 if (setAlwaysOnTopMethod == null) { 45 try { 46 System.loadLibrary("alwaysontop"); libLoaded = true; 48 } catch (Throwable t) { 49 libLoaded = false; 50 } 51 } 52 } 53 54 61 public static boolean setAlwaysOnTop(JDialog d) { 62 if (setAlwaysOnTopMethod != null) { 63 try { 64 setAlwaysOnTopMethod.invoke(d, new Object [] {Boolean.TRUE}); 65 return true; 66 } catch (Throwable ex) { 67 } 69 } 70 if (libLoaded) { 71 return setAlwaysOnTopWin32(d); 72 } 73 74 return false; 75 } 76 77 83 private static native boolean setAlwaysOnTopWin32(JDialog d); 84 } 85 | Popular Tags |