GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Close Group function via taskbar right-click menu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Close Group function via taskbar right-click menu" Watch "Close Group function via taskbar right-click menu" New topic
Author

Close Group function via taskbar right-click menu

Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
In WindowsXP, if you have multiple windows of a program (ex: many notepads, browser windows, etc), program titles on the taskbar gets grouped under the common name. (assumed that user have checked "Group similar taskbar buttons" in "Taskbar and Start menu Properties")

This allows user to right-click on grouped program taskbox on the taskbar and click "Close Group" that closes all the windows/instances of the group. How to handle this in a java application that has similar behavior(multiple windows) ?

There are several other related issues such as icon / task bar name changes upon taskbar grouping in Windows, which seems the only way around is to have a exe wrapper. (even if it doesn't seems to be the best solution)


Dilshan Edirisuriya SCJP1.4, SCWCD1.4, SCBCD 5
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

Originally posted by Dilshan Edirisuriya:
How to handle this in a java application that has similar behavior(multiple windows) ?


Why do you need to handle it yourself? The OS already handles it for you.
Or are you talking about JDesktopPane and JInternalFrame scenario?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
Thanks Maneesh.

Actually I have 5 separate JFrames in my application. So once i click on the close group button a message should popup asking user to save. But now when I click on the close group it happens only to a one frame not all 5 frames.

For my second issue I found a forum post. Check this.

http://forums.sun.com/thread.jspa?threadID=541940

According to this when I modify the registry entry It takes effect to the all applications which runs on the JRE. So without bundling my application in a separate JRE is there any solution?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10426
    
    8

Are you using a window listener and windowClosing() prompting the user to save? (The setDefaultCloseOperation should be set to DO_NOTHING_ON_CLOSE (default) )
I tried it and got prompted 5 times. How are you checking for window closing?

Of course this is not the only way. You can use Runtime#addShutdownHook(Thread hook) for example.

I don't see how the solution for the second problem can run on non Windoze platforms.
[ September 10, 2008: Message edited by: Maneesh Godbole ]
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
Thanks Maneesh

But that is not the actual scenario I want to handle. When we have multiple windows GROUPED as a single window, when we right click there is an close group option. So close group expected behavior is to close all the windows. But in my case it only affects to only one window.
 
GeeCON Prague 2014
 
subject: Close Group function via taskbar right-click menu