2

I want to blink my jframe's entry in taskbar but do not want it to get focused. I read about in on net and tried different solutions but none of them worked for me.

In my case I have a main jframe which has 2 buttons on click of which 2 jframes are opened. Both jframe listens to some event messages and on receiving of message it should blink if not focused.

I have tried following:

  1. frame.toFront();
  2. frame.requestFocus();
  3. frame.firePropertyChange();
  4. frame.setVisible(true);

They all worked well in blinking windows but the focus also gets transfered to that window which I don't want it do. How can I stop focus transfer? I have also tried calling transferFocus(); after the above options but didn't worked.

I have searched on SO but didn't find the solution. The questions I found are


My current code:-

public void OnEvent(){
    Toolkit.getDefaultToolkit().beep();  
    if(!hasFocus()){
         toFront(); //requestFocus(); //setVisible(true); //firePropertyChange("",false,true);
    }
}
Community
  • 1
  • 1
Harry Joy
  • 58,650
  • 30
  • 162
  • 207
  • 2
    sounds like you ought to be alternating the [icon image](http://download.oracle.com/javase/6/docs/api/javax/swing/JFrame.html#setIconImage%28java.awt.Image%29) of your `JFrame` instead of transferring focus. – mre Jun 21 '11 at 11:33
  • 1
    This seems like the exact sames question as: http://stackoverflow.com/questions/489255/using-swing-how-can-i-flash-the-windows-taskbar. Why not add a bounty to that question instead? – jzd Jun 21 '11 at 11:34
  • 1
    @jzd: because in that question OP has accepted an answer which does not solves my problem. – Harry Joy Jun 21 '11 at 11:37
  • @mre: setting icon image doesn't blink window and my application hangs doing this. – Harry Joy Jun 21 '11 at 11:43
  • I must have misunderstood you -- sorry. I thought you wanted the icon in the taskbar to "blink" whenever an event occurred and it didn't have focus! :) – mre Jun 21 '11 at 11:48

0 Answers0