?? sunkingjniutil.java
字號:
import java.awt.*;public final class SunkingJNIUtil { private SunkingJNIUtil() { } private static SunkingJNIUtil staticInstance; public static SunkingJNIUtil getDefault(){ if(staticInstance == null){ staticInstance = new SunkingJNIUtil(); String jawt=System.getProperty("java.home") +System.getProperty("file.separator") +"bin"+System.getProperty("file.separator") +"jawt.dll"; staticInstance.init(jawt); } return staticInstance; } private native void init(String jawt); public native void setStayOnTop(Component frame,boolean stay); public native void flashTitle(Component f); static{ String jdkver=System.getProperty("java.version"); if(jdkver.startsWith("1.3")){ System.loadLibrary("StayOnTop1_3"); }else{ System.loadLibrary("StayOnTop"); } } /** * Fix bug for jdk1.3<BR> * in jdk1.3 you must add this in a visible bounds<BR> * and canvas's paint method can be invoke,ex:<BR> *<BR> * import java.awt.*; <BR> * import java.awt.event.*;<BR> * import javax.swing.*;<BR> *<BR> * public class TestStayOnTop extends JFrame {<BR> * private Canvas STAY_ON_TOP_CANVAS =<BR> * SunkingJNIUtil.createJDK1_3StayOnTopCanvas();<BR> * public TestStayOnTop() {<BR> * this.setSize(400,300);<BR> * STAY_ON_TOP_CANVAS.setBounds(new Rectangle(0, 0, 1, 1));<BR> * this.getContentPane().setLayout(null);<BR> * this.getContentPane().add(STAY_ON_TOP_CANVAS, null);<BR> * setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<BR> * }<BR> * public static void main(String[] args) {<BR> * TestStayOnTop frame = new TestStayOnTop();<BR> * Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();<BR> * Dimension frameSize = frame.getSize();<BR> * if (frameSize.height > screenSize.height) {<BR> * frameSize.height = screenSize.height;<BR> * }<BR> * if (frameSize.width > screenSize.width) {<BR> * frameSize.width = screenSize.width;<BR> * }<BR> * frame.setLocation((screenSize.width - frameSize.width) / 2,<BR> * (screenSize.height - frameSize.height) / 2);<BR> * frame.setVisible(true);<BR> * frame.show();<BR> * }<BR> * }<BR> */ public Canvas createJDK1_3StayOnTopCanvas(){ return new Canvas(){ boolean isFirst = true; public void paint(Graphics g){ if(isFirst){ SunkingJNIUtil.getDefault().setStayOnTop(this,true); isFirst=false; } } }; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -