国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

怎樣讓窗口始終在前

2019-11-18 13:20:38
字體:
供稿:網(wǎng)友

  1,The upstair tell you a best way.
  2,You can extends JWindow
  override show() like this:
  public void show()
  {
  super.show();
  this.requestFocus();
  }
  and then add a window listener for
  the focus lost event:
  
  addFocusListener (new java.awt.event.FocusAdapter () {
  public void focusLost (java.awt.event.FocusEvent evt) {
  this.toFront();
  }
  }
  );
  It seems to work for me...
  
  3.You can also try to use thread, I recommend this way.
  /**
  * Call this from class consrUCtor
  */
  public void initialize() {
  TopThread top = new TopThread();
  top.start();
  }
  
  /**
  * Keep JWindow on top (inner class)
  */
  class TopThread extends Thread {
  public void run() {
  while(true) {
  toFront();
  /**
  * Let 10 milliseconds for other code to execute
  */
  try {
  Thread.sleep(10);
  }
  catch(Exception e) {
  // do what you wanna do
  }
  }
  }
  }
  
  You can see:http://forum.java.sun.com/thread.jsp?forum=57&thread=166992
  That's some others discuss it.

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 塘沽区| 沙坪坝区| 浦江县| 武陟县| 辽源市| 东方市| 红原县| 万全县| 凤城市| 罗山县| 黑龙江省| 神池县| 黔东| 东方市| 盐山县| 吉安市| 阳谷县| 饶河县| 万源市| 定兴县| 汝南县| 临潭县| 庆云县| 广元市| 育儿| 大姚县| 西盟| 临夏市| 静乐县| 武强县| 建平县| 德清县| 茌平县| 修文县| 谷城县| 天祝| 梧州市| 左权县| 娄烦县| 镇赉县| 綦江县|