File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes how to keep the popup while clicking on JCheckBoxMenuItem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to keep the popup while clicking on JCheckBoxMenuItem?" Watch "how to keep the popup while clicking on JCheckBoxMenuItem?" New topic
Author

how to keep the popup while clicking on JCheckBoxMenuItem?

Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73
Hi there;
As we know, the pop-up of a (J)Menu will be disappeared after click on its (J)MenuItem or JCheckBoxMenuItem (the latter is my case).
So i want to know either if it is possible to force it not disappear or if i should another equivalent

Actually I'm looking a way for check box menu item, because user may want to switch between checking/unchecking without disappearing the pop-up and have to click on menu(s) again and again

Thank you


I'm really tired of being engaged with stuff other than Java and programming

Wish to get back soon to my love...
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5

Here's a UI delegate I wrote some time ago for the same purpose.You can set this UI to individual JCheckBoxMenuItems using setUI(...) or, if this is the behavior you want for ALL JCheckBoxMenuItems in your application, you can make it the default using


luck, db
There are no new questions, but there may be new answers.
Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73
0umm,that looks pretty nice...
Thank you Darryl, i used your deligate as an inner class in my UI class and then invoked setUI() and that worked well, but for overriding the UI Manager, i got Error!
I should mention that i override the JCheckBoxMenuItem class too! lets look at the snippets:

before creating my class i have several overrides, latest is your suggestion, and i used it as several flavors:


the method below does the all gUI stuff creation:

and the same error i get every time:

I think i should compile your given delegate and place its class in the extension folder..., or something else

Again, thank you very much
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5



Isn't your UI class in a package? You need to put the fully qualified class name to the UIManager, as shown in my code sample.

The other two attempts, where you put an instance of the class, just don't make sense.

For a better understanding of how this stuff works, read the source code for the relevant classes. You can find the JDK sources in src.zip in your JDK folder.
Esmaeil Ashrafi
Ranch Hand

Joined: Feb 22, 2010
Posts: 73
Dear Darryl,
I was using your given delligate in the same file as UI was saved (as an inner class), now i create a seperate file for that and placed that in the same package as my UI class exists, so this resolved an currently works perfect.
Thank you for all your gentleness.
P.S: No, i just created a new project in NetBeans and this have no package (just two class, now three ) and the pranthesses in the value in the statement was just a typo ,sorry for that.

best of regards
Esmaeil Ashrafi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to keep the popup while clicking on JCheckBoxMenuItem?