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 change third level sub menu item position? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to change third level sub menu item position?" Watch "how to change third level sub menu item position?" New topic
Author

how to change third level sub menu item position?

ertan eyimaya
Greenhorn

Joined: Feb 16, 2005
Posts: 14
Hi,

I have a popup menu up to four level. Let's say : Aaaaaaa->Bbbbbbb->Ccccccc->Ddddddd

When mouse is right clicked at right bottom of the screen Popup menu is shown. If I move mouse on Aaaaaaa since no place for second level,
Bbbbbbb is shown at left of Aaaaaaa, then if I move mouse on Bbbbbbb then Ccccccc appears at right of Bbbbbbb. Problem is here,
I want Ccccccc is displayed left of Bbbbbbb and Ddddddd is at left of Ccccccc. All sub menus should opened towards left.

Note: This of course should be reverse when I right click at left bottom of screen. This time I want all submenus will be opened at right of it's parent.

thanks....
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

The behavior you describe is the default behavior of submenus on pretty much all windowed systems. You can find the code that computes the desired screen location in the method getPopupMenuOrigin() of JMenu.java.

If this is important enough to you, you could try extending JMenu to obtain the desired behavior. Won't be easy though -- that method is 120 lines long.


luck, db
There are no new questions, but there may be new answers.
ertan eyimaya
Greenhorn

Joined: Feb 16, 2005
Posts: 14
thanks for your reply. I'll try it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to change third level sub menu item position?
 
Similar Threads
Problem in Jpopup Menu
popup menu query
DIV and CSS Help
Problem with struts-menu for second level submenu
JTextFiled and Jpopupmenu