Solved

Flashing application in taskbar

Posted on 2006-07-17
19
1,193 Views
Last Modified: 2011-10-03
I don't really know how to explain this... When you're MSN is minimised and you get a new message, the MSN window flashes in the main app and in the taskbar at the bottom of the screen.

Does anybody know how to do this for a java app? It will be triggered by a dialog that opens which is triggered by a change in the database, and this same dialog will trigger an event to stop flashing, So there is no problem with that part of it.

Thanks
0
Comment
Question by:riaancornelius
  • 8
  • 3
  • 3
  • +5
19 Comments
 
LVL 1

Expert Comment

by:sree032397
ID: 17128166
You can achieve it programmatically.
create a new field in database called status, By default it should be false

Then in your program create a thread. In thread continuously check(using while(true)) for databse for false in status. If you got it then process it and make it true. But dont forget to give a delay(5 seconds prefered using Thread.sleep(5000) ). This is to prevet crashing of database(Since connecting continuously may crash it)

Hope it works Since I am useing this technique now.
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17128244
You misunderstood. I already have a dialog which opens when the db field changes. This is not the problem. The problem is with the actual flashing of the window. I have no idea how to do it. Is there some library that will enable me to do it - I know it needs to be native code, but I'm not writing it :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 17128311
Hi riaancornelius

what version of java are you using? In Mustang there is a default library to do it: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/systemtray/ and http://www.devx.com/Java/Article/30861/0/page/4. If you are using an earlier version you need something like the following: http://systray.sourceforge.net/, or maybe this is a good start: http://today.java.net/pub/a/today/2003/12/08/swing.html (go to the section "Native User Alerts for Windows").

Cheers
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17128369
Thanks girionis, will have a look at those links later. We're sticking with Tiger for the moment.
0
 
LVL 2

Expert Comment

by:frube
ID: 17128475
Hi, if you only plan on using this feature on the windows platform there is a much simpler answer, (I'm only assuming this based on you mentioning the MSN program.) Using the toFront() method calls the Win32 SetWindowPos and SetForegroundWindow APIs. SetForegroundWindow will flash the taskbar if the calling application is not the foreground app. Calling toFront() on other platforms will not have the desired effect.

Hope this helps.
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17128599
Thanks frube, I'll have a look at that. You are correct about it being only on windows platform.
0
 
LVL 1

Expert Comment

by:pthorson
ID: 17133279
Yes toFront has this effect for apps that are not in the foreground. The functionality is slightly different based on the version of Java and Windows. You should only need to call it once. The flashing is on the windows side of things so I don't think it will stop until the user brings the app to front. In an app we were calling toFront in a loop. After a minor windows update, this prevented the user from doing anything else so we modified it to only call toFront once.
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17135866
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17136082
Ajay-Singh, that's only for non commercial use. Afraid I can't use it.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:Trooper80
ID: 17139414
If you can't wait for J2SE 6.0 and you know a bit of C++ then try JNI yourself
http://www.javaworld.com/javaworld/jw-10-1999/jw-10-jni.html
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17144026
>> what version of java are you using? In Mustang there is a default library to do it: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/systemtray/ and http://www.devx.com/Java/Article/30861/0/page/4.

Mustang seems awesome, but we can't risk using it until final release. The product I need this for is a commercial app of about 500 000 lines which is distributed to thousands of users all around the world.

>> If you are using an earlier version you need something like the following: http://systray.sourceforge.net/,
That will only let you do menu's in systray.

>> or maybe this is a good start: http://today.java.net/pub/a/today/2003/12/08/swing.html (go to the section "Native User Alerts for Windows").
>> If you can't wait for J2SE 6.0 and you know a bit of C++ then try JNI yourself
http://www.javaworld.com/javaworld/jw-10-1999/jw-10-jni.html
Err, no. I'm not going down that road again... Me and JNI is not friends...
0
 
LVL 35

Expert Comment

by:girionis
ID: 17144061
> Err, no. I'm not going down that road again... Me and JNI is not friends...

I am afraid there is no other way to do it then, in the current versions of JDK.
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 500 total points
ID: 17144085
If you don't like JNI that much you can try to use JNI wrapper which will abstract some of the JNI intricacies from you:

http://www.jniwrapper.com
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17144125
mayankeagle, Do you know if there's anything in there that can do the flashing of the window. I'm sure winpack must have something?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 17144145
No, sorry never tried flashing of the window using it but you can definitely use it wherever JNI is applicable :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 17144224
Winpack does have some tray icon windows applications, have a look here: http://www.jniwrapper.com/jniwrapper_downloads/demo/winpackdemo.jnlp for a webstart demo. But even if you find something liek this you will need a licence to use it.
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17144396
>> Winpack does have some tray icon windows applications, have a look here: http://www.jniwrapper.com/jniwrapper_downloads/demo/winpackdemo.jnlp for a webstart demo.
I say that. Looks pretty usefull.
>> But even if you find something liek this you will need a licence to use it.
Turns out we actually have a license for that, so no prob :)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 17144507
That sounds great, JNI wrapper is anyway worth a buy I would say :)
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17144604
Looking at it, I have to agree with you :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now