Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"

Raymond du Toit

+ Follow
since Jun 29, 2005
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Raymond du Toit

Sounds like a good idea, thanx. I will try that.
17 years ago
e.consume() does not seem to work on JMenuItems.
It only seems to work on buttons. If I put an operation and e.consume() in one of the MouseListener methods, it seems to ignore e.consume(), executes the operation and closes the menu.

Thanx anyway!
17 years ago
I need help with a mouse listener on a menu I made.
I added a mouse listener to the each Menu item. If a user left clicks the menu item, it opens the option. But if he right clicks on the menu item, it should keep the menu open and display the right click popup menu. I got the popup menu to display on right click, but the menu closes, so the user cannot see which item he right clicked on.

Is it possible to override the default close operation of Jenu and keep the menu open until I left click on the menu item?

Thank You
17 years ago
I fixed the problem by adding the following code:

17 years ago
I really need help!
I have a JMenubar containing a few JMenu's. One of the menu's have submenu's (JMenu) and then one of these menu's contain some submenu's (JMenu).
Here is the method I use to populate the menu with either JMenuItem's or JMenu's. The problem is that some of the submenu's or JMenu's in the main JMenu does not open when the mouse pointer is moved over it. Does anyone have suggestions, please?
public void populateMenu(JMenu menu, ArrayList al){

HTMLLink linkObject;

for(int i=0; i< al.size(); i++){
linkObject = (HTMLLink) al.get(i);
if(linkObject.getLink() instanceof ArrayList){
JMenu itemMenu = new JMenu(linkObject.getName());
populateMenu(itemMenu, (ArrayList)linkObject.getLink());
menu.add(new JMenuItem(linkObject.getName()));
17 years ago
I have a web browser application with a favorites menu. The menu has an two options to import favorites from IE and Firefox. When the application imports favorites from IE, it places the favorites as items under the import option. If there are folders of favorites, it will add a submenu containing the favorites in the folder.
The problem I have is that after I import the favortites and it creates the submenus, some submenu's don't open the mouse pointer is moved over them.
Some menu work fine and when the mouse pointer is moved over such a, then the other submenu open fine as well, but only after selecting a submenu that listens.

I have debugged the code and the menu items are added before selecting the menu. I don't need a listener for a submenu?

Does anyone have an idea what I am overlooking?
17 years ago