Questions tagged [jpopupmenu]

JPopupMenu is the Java Swing implementation of a popup menu, a small window that pops up and displays a series of choices. A JPopupMenu is used for the menu that appears when the user selects an item on the menu bar. It is also used for "pull-right" menu that appears when the selects a menu item that activates it. Finally, a JPopupMenu can also be used anywhere else you want a menu to appear.

JPopupMenu is the Java Swing implementation of a popup menu, a small window that pops up and displays a series of choices. A JPopupMenu is used for the menu that appears when the user selects an item on the menu bar. It is also used for "pull-right" menu that appears when the selects a menu item that activates it. Finally, a JPopupMenu can also be used anywhere else you want a menu to appear.

For information and examples of using popup menus, see How to Use Menus in The Java Tutorial.

255 questions
3
votes
1 answer

JTabbedPane tabs

Alright, so I have a JTabbedPane in an application and it has several panels. Is it possible to assign a JPopupMenu to the actual tabs themselves instead of the JPanel? If it is possible, how would I do this?
user372743
3
votes
1 answer

Difference between LookAndFeel behavior

I created a JPopupmenu and i added a JTextField. When I am using metal or nimbus everything is alright. The problem is when I switch LookAndFeel to Windows. I can not press right ALT, because if I press this key, JPopupmenu will hide. Can I use…
Zbijlud
  • 73
  • 5
3
votes
0 answers

Java - setSelectedIcon() and setPressedIcon() do not seem to register

I have a JPopupMenu on a JTree with JCheckboxMenuItem's where I would like to use custom icons (Windows L&F). I'm able to use setIcon() on a JCheckboxMenuItem successfully, but for some reason setSelectedIcon() and setPressedIcon() do not appear to…
IDontWorkAtNASA
  • 193
  • 2
  • 16
3
votes
3 answers

JPopupMenu change size dynamically if there is a JPanel inside

I have a JPopupMenu and I want to change it's inner size dynamically depending on it's inner components' size. In my SSCCE I described the problem. SSCCE: public class PopupTest2 { public static void main(String[] a) { final JFrame frame…
SeniorJD
  • 6,946
  • 4
  • 36
  • 53
3
votes
4 answers

Get JPopupMenu size before it is shown

I have the JPopupMenu shown on right mouse click. I want JPopupMenu' top right corner to be at the click location (not top left one, as default). To perform this, I need to set the X coordinate as mouseEvent.getX() - popupMenu.getWidth(). The…
SeniorJD
  • 6,946
  • 4
  • 36
  • 53
3
votes
1 answer

Get XY position from caret position in JTextArea

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…
TblsX
  • 73
  • 3
  • 13
3
votes
2 answers

Setting the JFrame background transparent making PopupMenu blank

My question is similar to this, but I think has a simpler example. Basically by calling AWTUtilities.setWindowOpaque(window, false) to make the background of the JFrame transparent, my JPopupMenu sometimes show up as blank. public class…
kir
  • 581
  • 1
  • 6
  • 22
3
votes
2 answers

Java jpopupmenu on mouseExited

I'm trying to create system tray icon with two popup menus, one should be called with left mouse button and another with right. AWT offers simple way to create PopupMenu but it's not posible to call menu with left mouse button without making…
Algirdas
  • 33
  • 4
3
votes
1 answer

JComboBox with JPopupMenu as right click option

So the functionality I need is the Combobox which upon expansion can be right clicked and then a popup menu shows which shows different actions. For that I extended the JCombobox with following constructor: public…
Marko
  • 151
  • 1
  • 13
3
votes
6 answers

JMenuItem.setSelected() does not alter appearance of selected item?

I wish to programmatically cause a particular item on a menu to be selected and to display as such so that if Enter is pressed, the corresponding action will be performed. Ubnfortunately I find that neither JMenuItem.setSelected(), nor…
Steve Cohen
  • 4,679
  • 9
  • 51
  • 89
3
votes
1 answer

Update SystemTray dynamically in java

Is it possible to add an item to a PopUpMenu in the SystemTray in java? I have tried to add the item to the menu, but that dosen't work. Neither does adding it and call the TrayIcon.setPopMenu(PopUpMenu) and afterwards the SystemTray.add(TrayIcon)…
gedemagt
  • 657
  • 1
  • 9
  • 22
3
votes
5 answers

Swing persistent popup

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…
Ilya Ivanov
  • 2,379
  • 1
  • 21
  • 24
3
votes
1 answer

Mnemonics (underlined letters) on popup menus in Java Swing on Windows XP

I'm having some trouble getting the underlines to show up consistently for mnemonics on context menus in a Java Swing application that's running on Windows XP. If I right click the mouse, the underlines don't show up on the popup menu -- that is…
Gigatron
  • 1,995
  • 6
  • 20
  • 27
3
votes
2 answers

showing Popup box on Right click at JTree node swing

I want to show popup box on a right-click at JTree node only, not for the whole JTree component. When user right-clicks on a JTree node then popup box comes up. If he right-clicks a blank space in JTree then it should not come up. So for that how…
user591790
  • 545
  • 2
  • 15
  • 33
2
votes
3 answers

Java rowAtPoint() does not return a proper value

I am making a java project and i am using JTable. The thing i want to do is link a popupmenu to the jtable. The popupmenu has four different items. Some of the items need to know selected row in jtable. The problem is in selectRow -function. i…
Painkiller
  • 109
  • 1
  • 1
  • 10