wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to get default menu items from JDialog? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to get default menu items from JDialog? " Watch "How to get default menu items from JDialog? " New topic
Author

How to get default menu items from JDialog?

Jack Wanes
Greenhorn

Joined: Sep 18, 2006
Posts: 22
I have a JDialog with default menu bar with menu items such as "Move", "Size", and "Close". I am trying to
get the "Move" menuItem and then programatically do a click on it. But I cannot get this menu item using the following piece of code:




I guess there must be a way to get this. Any idea?

regards,
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

What you have isn't a JMenuBar. It's something the OS puts on window title bars. You can't get to it directly through java. At least, not that I am aware of.


GenRocket - Experts at Building Test Data
Jack Wanes
Greenhorn

Joined: Sep 18, 2006
Posts: 22
Thanks for the clarifications. So we have no way to do this?

I guess I have to create another menu to simulate its behavior.

thanks,


Gregg Bolinger wrote:What you have isn't a JMenuBar. It's something the OS puts on window title bars. You can't get to it directly through java. At least, not that I am aware of.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

What behavior?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

If you want to move your JDialog around programatically, check out the setLocation() method.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Jack Wanes
Greenhorn

Joined: Sep 18, 2006
Posts: 22

The behavior of that Move menu item.

Gregg Bolinger wrote:What behavior?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19674
    
  18

Use a MouseInputListener to implement it yourself:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to get default menu items from JDialog?