jpopupmenu

System Tray Pop up menu item with Image(Icon to the MenuItem)

血红的双手。 提交于 2019-12-10 11:41:16
问题 I read the system tray tutorial and this similar Stack Overflow question but can't find a good answer. I want to add an image to menu item in J2SE application. In the tutorial, MenuItem is used, but I couldn't find how to add icons to menu items in SystemTray pop up. If JMenuItem is used, icons can easily be placed in MenuItems , but there is MenuItem . How can I add an image to my system tray popmenu? Updated Here, I want to add an image to MenuItem in the popup menu(not to the SystemTray.)

Swing persistent popup

随声附和 提交于 2019-12-10 10:14:32
问题 I need to display a swing popup with my custom component. The popup should stay visible, until I hide it myself, but shouldn't get focus. I have a code written by some other developer that does it in the following way: popupMenu = new JPopupMenu(); popupMenu.add(myCustomComponent, BorderLayout.CENTER); popupMenu.setFocusable(false); popupMenu.setVisible(true); popupMenu.show(parentComponent, x, y); This seems to work, but has a bug - when the popup is visible, first mouse click outside the

Java JPopupMenu bug

只愿长相守 提交于 2019-12-10 07:25:33
问题 Seems like I've found a bug in Java: I need to create the JFrame with a transparent background and now I need to show the JPopupMenu for some user actions. It works fine when JPopupMenu is housed fully inside a JFrame . But when the JPopupMenu is partly outside the JFrame , no item is visible. SSCCE: public class PopupTest { public static void main(String[] a) { final JFrame frame = new JFrame(); frame.setSize(500, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JPanel panel

JPopupMenu in JFrame using AWTUtilities.setWindowOpaque(window, false) using synth L&F not appearing

天大地大妈咪最大 提交于 2019-12-08 03:15:03
问题 This one has me quite puzzled. Basically I am developing a multi window application using transparent shaped windows using a custom Synth L&F. Parts of the application invoke JFrame / JDialog components from the parent frame. Within these components I have pop up menus and comboboxes, the problem is that some people using the applications experience the pop up menus not appearing when invoked. There are no exceptions and the code executes fine including for popup menus 'show' method. I have

Java JPopupMenu Mac OS X

╄→гoц情女王★ 提交于 2019-12-07 08:14:13
问题 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.

How to get focus in JPopupMenu

…衆ロ難τιáo~ 提交于 2019-12-07 02:59:30
问题 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

JTable - Toggle Columns with PopupMenu (like Windows Explorer)

跟風遠走 提交于 2019-12-06 10:04:10
问题 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

JPopupMenu Behavior

随声附和 提交于 2019-12-06 08:01:31
I prepared a small test case below. My problem is when i right click on the window. JPopupMenu show up but if i click anywhere outside the JWindow menu does not disappear. I have to click somewhere on the window to get rid of it which is not the expected behavior. EDIT: after reading akf's answer i switched to JFrame, when frame is in focus and pop up menu is showing it disappears when you click on another window. but if the window does not have focus and you click somewhere menu does not disappear. import javax.swing.*; import java.awt.*; import java.awt.event.*; class test { static class

Get XY position from caret position in JTextArea

穿精又带淫゛_ 提交于 2019-12-06 04:22:56
I'm trying to make an editor which have ability show pop up (JPopupMenu) each time users type any letter. Maybe, to imagine how my editor works its like any compiler, such as NetBeans when we type dot, the function appear. I have learned JPopupMenu from here . JPopupMenu needs XY position. My idea is to get XY position from JTextArea's caret position. My question is: Is there possible to get XY position from caret position (text cursor) in JTextArea or other JTextComponent? Or maybe is there any solution better to this case? Thx before. Sorry, not good in english. :D Rectangle rectangle =

Swing persistent popup

血红的双手。 提交于 2019-12-05 21:37:56
I need to display a swing popup with my custom component. The popup should stay visible, until I hide it myself, but shouldn't get focus. I have a code written by some other developer that does it in the following way: popupMenu = new JPopupMenu(); popupMenu.add(myCustomComponent, BorderLayout.CENTER); popupMenu.setFocusable(false); popupMenu.setVisible(true); popupMenu.show(parentComponent, x, y); This seems to work, but has a bug - when the popup is visible, first mouse click outside the component is consumed by the popup. So I need to click twice to set focus to another component. How can I