How can I flash the Windows taskbar using Swing?

I’m developing a Swing application and I need to flash the Windows taskbar. I can’t use frame.requestFocus() because I don’t want to steal focus from any other application.


I don’t know if it applies to newer versions of Windows, but the .toFront() method used to flash the window if none of the current VM’s windows were in the foreground.

This means that calling frame.toFront() on a minimized frame would always make it flash…


Best Practice for Using Java System Properties

Our code uses a lot of system properties eg, ‘’, ‘user.home’, ‘’ etc. We do not have any constants defined for these anywhere (and neither does java I think) or any other clever thing for dealing with them so they are in plain text littered throughout the code.

String tempFolderPath = System.getProperty("");

How is everyone using system properties?


I would treat this just as any other String constant you have scattered throughout your code and define a constant variable for it. Granted, in this case “” is unlikely to change, but you never know. (I don’t mean that Sun might change the meaning of “”, or what system property it points to, but that you might change your mind about what system property you need to read.)

If you’re only using a particular property within one class, then I’d define the constants right in that class.

private final String TEMPDIR = "";

If you’re using the same properties in different classes, you may want to define an static class of your own to hold the constants you use most often.

public final Class Prop {
    public static final String TEMPDIR = "";

Then, everywhere you need to use that constant just call it using


Registering a dynamic javascript after an UpdatePanel’s update

I have a page with a dynamicly created javascript (the script is pretty static really, but the value of its variables are filled based on user input).

The result and the controls to take user input is inside an UpdatePanel which updates itself on certain user intputs. Some of these userinputs cause changes in the variables i spoke of earlier so i need to register a new javascript.

The problem ofcourse is that only the updatepanel gets updated and the scripts are registred outside the update panel so no new scripts are added.

What do you think would be best practice now? I could solve this by letting this script (and variables) live inside the updatepanel or i could make sure the page is fully reloaded when the need for posting a new javascript arises? The ScriptManager that i already have on the page might be able to help me with this…

So i’m looking for someone who either had similar problems and solved them in a nice way, or just someone with some bright ideas 🙂


Why not just put the variables inside the update panel, or have the JavaScript get the values through the DOM?


What’s the correct/proper way to test if an object is a jQuery object in javascript?

I’m writing a javascript function and in “compact” javascript design fashion, the type/length of arguments changes the behaviour of the function. One possible type of the argument is a jQuery object, for which I would like very special logic.

What is the best way to test if an object is an instance of jQuery?


Depends on the inner workings of jQuery, but I’d go with

obj instanceof jQuery

It’s the most ‘JavaScript way’ of doing it. Keep in mind that it will fail when passing objects between window/frame boundaries!

Tomalak’s suggestion

'jquery' in obj

should still work in this case, so you should use it if you expect to do multi-window data exchange. I wouldn’t recommend it as a general solution, as just looking for a property named 'jquery' isn’t very reliable.

The in operator will also throw an error if obj is a primitive. If this behaviour is undesired, you might consider using one of these tests instead:

obj && obj.jquery
'jquery' in Object(obj)

I find the second one more appealing, but the first one will likely be faster.



will fail, as jQuery objects only inherit the property from their prototype.

I’d also discourage using the constructor property for type checking in JavaScript – it might work reliably for jQuery, but as constructor is just a property of the object pointed to by the constructor function’s prototype property at instantiation time, there are lots of ways to mess with such tests…

As a side note:

jQuery itself checks for obj && obj.jquery. It does not use instanceof even once. Instead, it uses a combination of typeof, duck-typing and for type checking, which should work where instanceof will fail.

Also, hasOwnProperty() is never used as well. I’m not sure what this says about the code quality of the jQuery library 😉

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..