jpopupmenu

How to prevent JPopUpMenu disappearing when checking checkboxes in it?

妖精的绣舞 提交于 2019-12-20 14:20:13
问题 I want to use JCheckBoxMenuItem s in a JPopupMenu . It works, but the problem is that the popup menu disappears when a checkbox item has been checked or unchecked. So if one wants to check/uncheck several items, the popup needs to be launched repeatedly, which is irritating. Curiously, if I use just plain JCheckBox items in the menu (instead of JCheckBoxMenuItem s), the behavior is just as it should be: the popup stays there and the checkboxes can be checked/unchecked. Once done, the popup

Showing/hiding a JPopupMenu from a JButton; FocusListener not working?

点点圈 提交于 2019-12-19 16:34:38
问题 I needed a JButton with an attached dropdown style menu. So I took a JPopupMenu and attached it to the JButton in the way you can see in the code below. What it needs to do is this: show the popup when clicked hide it if clicked a second time hide it if an item is selected in the popup hide it if the user clicks somewhere else in the screen These 4 things work, but because of the boolean flag I'm using, if the user clicks somewhere else or selects an item, I have to click twice on the button

JMenu consumes focuslost event in Windows7 LAF Java7

北城余情 提交于 2019-12-19 10:43:24
问题 If a popup menu is still open when another component is clicked, then the component does not get the event, because it's probably consumed by the popup. This happens for all JPopupmenus in general. This happens only in Java 7 with windows LAF (Windows7). Is there a workaround? Is it a known bug? import javax.swing.*; import java.awt.event.*; public class Test { public static void main(String[] s) throws Exception { String lookAnfFeelClassName = UIManager.getSystemLookAndFeelClassName();

JMenu consumes focuslost event in Windows7 LAF Java7

梦想与她 提交于 2019-12-19 10:42:26
问题 If a popup menu is still open when another component is clicked, then the component does not get the event, because it's probably consumed by the popup. This happens for all JPopupmenus in general. This happens only in Java 7 with windows LAF (Windows7). Is there a workaround? Is it a known bug? import javax.swing.*; import java.awt.event.*; public class Test { public static void main(String[] s) throws Exception { String lookAnfFeelClassName = UIManager.getSystemLookAndFeelClassName();

JPopupMenu on JTable -> Get the cell the menu was created on

只愿长相守 提交于 2019-12-18 06:50:51
问题 I have a situation where I have a popup menu created when a JTable is right clicked on. Standard way of creating the popup menu: aJTable.setComponentPopupMenu(rightClickMenu); Now afterwards in the action that gets registered, I am unable to find out which cell was right clicked on to get that popup menu to appear. rightClickMenuItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { // Work out what cell was right clicked to generate the menu } })

JPopupMenu closes when child popup opens

穿精又带淫゛_ 提交于 2019-12-17 14:56:06
问题 I have a JComboBox (among other components) inside a JPopupMenu. It turns out that whenever I open the combo box's popup (to select an item), the parent JPopupMenu closes. I've been trying to find a way to override this feature, to no avail. Does anyone have any suggestions to prevent closing the parent JPopupMenu? Thanks! 回答1: that not possible directly, its very hard to override known bug, in other hands Swing doesn't allows two lightwieght popup components in same time import javax.swing.*

Java/Swing/Mac OSX: Converting JMenu to JPopupMenu using ScreenMenuBar

旧巷老猫 提交于 2019-12-12 03:32:11
问题 I have an application that has a main GUI with a menubar, and another fullscreen frame, which makes some parts of the main GUI appear in fullscreen exclusive mode. When I am in fullscreen mode, I would like to bind a drop-down menu from the menu bar as jpopupmenu. Swing provides the function getPopupMenu() in JMenu. This function seems to work fine at first glance. I can hover over the menuitems and move to and view the submenus. Hovering over the submenus does emphasize the submenus,

Prevent JPopupMenu from closing when ALT is pressed

不羁岁月 提交于 2019-12-11 21:55:16
问题 hopefully someone can give some help. I want to use the filter for JTables from swingbits. I wanted to use the buildin opportunity to filter the distinct items by regular expressions. The big problem is, it seems impossible to enter a | (pipe) in the search field. The popup (based on JPopupmenu) always closes just when pressing Alt-Gr. I tried to remove the keybindings for Alt-Gr, with no effect. It seems it is somewhere deep inside. Any ideas how to solve this? Thanks in advance. Juliane 回答1

How to setSelected by name some JMenuItem in a JPopUpMenu?

纵然是瞬间 提交于 2019-12-11 05:19:20
问题 I have a JPopUpMenu with several JCheckBoxMenuItem's on it. I also have a properties files (config.properties) where I put a parameter which save every JCheckBoxMenuItem the user has checked on this JPopUpMenu , when i close the application. So this file is like : config.properties : listeFiltres =Autres,Afrique du sud,Algérie What I would like to do is , on the start of my application, to setSelected every item that is saved in my properties parameter. For exemple, if "Afrique,Algérie

Using visual swing JPopup menu in netbeans

岁酱吖の 提交于 2019-12-11 02:06:11
问题 i want to add a popup menu to my app but when i add it to my panel i see its disappear. how i can edit jpopup menu visualy like other menus? 回答1: I think you're talking about using the matisse visual designer in NetBeans. In which case the process is slightly different from creating menubar menus that you can just drag onto the screen. The steps to get this to work are as follows Drag a pop up menu on to the screen Go to the Inspector Window (Window -> Navigating -> Inspector) You will see an