熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

怎樣讓窗口始終在前

2022-06-13   來源: JSP教程 

  The upstair tell you a best way
  You can extends JWindow
  override show() like this:
  public void show()
  {
  supershow();
  thisrequestFocus();
  }
  and then add a window listener for
  the focus lost event:
  
  addFocusListener (new javaawteventFocusAdapter () {
  public void focusLost (javaawteventFocusEvent evt) {
  thistoFront();
  }
  }
  );
  It seems to work for me
  
  You can also try to use thread I recommend this way
  /**
  * Call this from class consructor
  */
  public void initialize() {
  TopThread top = new TopThread();
  topstart();
  }
  
  /**
  * Keep JWindow on top (inner class)
  */
  class TopThread extends Thread {
  public void run() {
  while(true) {
  toFront();
  /**
  * Let milliseconds for other code to execute
  */
  try {
  Threadsleep();
  }
  catch(Exception e) {
  // do what you wanna do
  }
  }
  }
  }
  
  You can see:?forum=&thread=
  Thats some others discuss it
  

From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19390.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.