显示/隐藏以JButtons为元素的JPopupMenu [英] showing/hiding JPopupMenu having JButtons as it's elements

查看:128
本文介绍了显示/隐藏以JButtons为元素的JPopupMenu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Friends

我正在使用JPopupMenu遇到问题.基本上,我有一个JPopupMenu,其元素是JButtons.现在,当我单击JPopupMenu的JButton元素之一时,需要打开一些与第一个Popup菜单中单击的JButton元素相对应的其他子菜单.现在我面临的问题是,当我在第一个弹出菜单中单击JButton元素时,子菜单将被打开,而第一个JPopupMenu将被关闭.但是我需要第一个JPopupMenu在显示子菜单时也保持打开状态.请帮助执行此操作...请记住,第一个JPopupMenu的元素不是JMenuItems而是JButtons.如何处理这种情况.请帮忙.

Hi Friends

I am facing a problem with JPopupMenu. Basically, I have a JPopupMenu whose elements are JButtons. Now When I click on one of the JButton element of the JPopupMenu, I need some other submenu to be opened corresponding to the clicked JButton element in the first Popup menu. Now the problem i am facing is, when I click the JButton element in the first popupmenu, the submenu is getting opened but the first JPopupMenu is getting closed. But I need that first JPopupMenu also to stay opened when showing the submenu. Please help how to do this...please keep in mind that the elements of the first JPopupMenu are not JMenuItems but JButtons. how to handle this situation. Please help. any example source code helps me.

推荐答案

JButtons?没有用于弹出菜单的JButton!您甚至是怎么做到的?

如何在Oracle.com上使用菜单 [
JButtons? There are no JButtons used for popup menus! How did you even manage to get them in there??

How to use Menus @ Oracle.com[^]

stick to MenuItems and you''ll have a much easier life.

regards
Torsten


嗨Torsten

我通过像往常一样声明JButton并将JButton添加到菜单中而不是添加JMenuItems来获得它,而我添加了JButtons.这样,我在菜单中找到了JButton.但是对我来说,拥有JButtons是强制性的要求,所以请朝这个方向帮助我.
Hi Torsten

I got it by declaring the JButtons as usual and adding the JButtons to the menu instead of adding JMenuItems I added the JButtons. In this way I got the JButtons in the menu. But having the JButtons is a compulsory requirement for me and so please help me in this direction.


His Torsten

我通过像往常一样声明JButton并将JButton添加到菜单而不是添加JMenuItems来获得它.这样,我在菜单中找到了JButton.但是对我来说,拥有JButtons是强制性要求,因此请朝这个方向帮助我.
Hi Torsten

I got it by declaring the JButtons as usual and adding the JButtons to the menu instead of adding JMenuItems. In this way I got the JButtons in the menu. But having the JButtons is a compulsory requirement for me and so please help me in this direction.


这篇关于显示/隐藏以JButtons为元素的JPopupMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆