jpopupmenu

Java JPopupMenu Mac OS X

时光怂恿深爱的人放手 提交于 2019-12-05 14:21:15
i have three problems with a JPopupmenu on Mac, all can be reproduced by the enclosed java program or e.g. the netbeans java application. The first thing is that Java applications don't block the dock when a popup menu is shown. So when i right click in my java application to open a popup menu, i can still move the mouse over the dock area and the dock appears. In non java applications (Outlook, Textwrangler, Finder...) the dock won't appear if a context menu is shown in these applications. Is there a way to make a java application behave like a 'native' OS X application, so the dock will not

How to get focus in JPopupMenu

泪湿孤枕 提交于 2019-12-05 06:36:57
I am an experienced Java programmer, but a Swing newbie so please bear with me. I wish to have a JPopupWindow which has keyboard focus. I want to respond to arrow keys, escape (to close the menu) and Enter (to invoke the item). Must I add a KeyListener to the menu and code all this myself, or is there some sort of "mode" I can set to activate this behavior which seems like it ought to be standard. The standard Swing tutorial section on JPopupMenus speaks only of mnemonics and accelerators. I don't particularly want those. Hard to believe that this is totally against the grain of JPopupMenu.

JTable - Toggle Columns with PopupMenu (like Windows Explorer)

十年热恋 提交于 2019-12-04 17:29:54
How would I go about creating a JTable in Swing that allows the user to toggle columns with a simple dropdown meun, like in Windows Explorer folders? My table has 12 columns, and the screen cannot fit all the information on the screen at once. Since the user may not need to see many of these columns, this seems like the best option. I assume it would use a JPopupMenu that appears when the user right-clicks the table header, with a JCheckBoxMenuItem for each column. Here's a screenshot of Window's column toggler that I'm trying to replicate: How would I go about creating a JTable in Swing that

Stopping JPopupMenu stealing the focus

末鹿安然 提交于 2019-12-04 09:18:13
问题 I have a JTextField for which I'm hoping to suggest results to match the user's input. I'm displaying these suggestions in a JList contained within a JPopupMenu . However , when opening the popup menu programmatically via show(Component invoker, int x, int y), the focus is getting taken from the JTextField . Strangely enough, if I call setVisible(true) instead, the focus is not stolen; but then the JPopupMenu is not attached to any panel, and when minimizing the application whilst the box is

How to prevent JPopUpMenu disappearing when checking checkboxes in it?

一曲冷凌霜 提交于 2019-12-03 03:43:31
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 can be closed just by clicking outside it. How do I make the popup to behave like that when the items

Stopping JPopupMenu stealing the focus

孤街醉人 提交于 2019-12-03 02:39:51
I have a JTextField for which I'm hoping to suggest results to match the user's input. I'm displaying these suggestions in a JList contained within a JPopupMenu . However , when opening the popup menu programmatically via show(Component invoker, int x, int y) , the focus is getting taken from the JTextField . Strangely enough, if I call setVisible(true) instead, the focus is not stolen; but then the JPopupMenu is not attached to any panel, and when minimizing the application whilst the box is open, it stays painted on the window. I've also tried to reset the focus to the JTextField using

How can i make a JPopupMenu transparent?

∥☆過路亽.° 提交于 2019-12-01 18:54:17
I'd like to customize the look of JPopupMenu so i made a custom class extending the JPopupMenu class on i overrode the paintComponent method as i would do for any component i need to customize. public class CustomPopupMenu extends JPopupMenu { @Override public paintComponent(Graphics g) { //custom draw } } The only problem i have right know is that i'm not able to make the JPopupMenu transparent. I though setOpaque(false) would be enough, i was wrong. How can i make a JPopupMenu transparent? The problem with a popup menu is that it may be realized as a top-level container (Window), and a

JPopupMenu is not displayed on right click

二次信任 提交于 2019-12-01 14:03:12
import java.awt.FlowLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; public class B extends MouseAdapter { JFrame frame = new JFrame(); JPopupMenu popup = new JPopupMenu(); JMenuItem item1 = new JMenuItem("ADD"); JMenuItem item2 = new JMenuItem("DELETE"); public static void main(String arg[]) { new B(); } B() { frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setLayout(new FlowLayout()); frame.addMouseListener(this); popup.add(item1); popup.add(item2); frame.add(popup);

JMenu consumes focuslost event in Windows7 LAF Java7

▼魔方 西西 提交于 2019-12-01 11:36:57
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(); UIManager.setLookAndFeel(lookAnfFeelClassName); JMenu menu = new JMenu("TEST Menu"); JMenuItem menuItem =

JPopupMenu is not displayed on right click

。_饼干妹妹 提交于 2019-12-01 11:34:59
问题 import java.awt.FlowLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; public class B extends MouseAdapter { JFrame frame = new JFrame(); JPopupMenu popup = new JPopupMenu(); JMenuItem item1 = new JMenuItem("ADD"); JMenuItem item2 = new JMenuItem("DELETE"); public static void main(String arg[]) { new B(); } B() { frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setLayout(new