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
6
votes
2 answers

JPopupMenu display under Canvas

I have a Canvas, some text fields and a context menu. When I start the application and right click on the canvas a popup menu shows. But when I write something inside the text field than I right click on the canvas, the popup will shows behind the…
Guillaume Massé
  • 8,004
  • 8
  • 44
  • 57
6
votes
1 answer

JPopupMenu closes when child popup opens

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…
Sam
  • 259
  • 2
  • 13
6
votes
2 answers

How to get focus in JPopupMenu

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…
Steve Cohen
  • 4,679
  • 9
  • 51
  • 89
6
votes
2 answers

How to prevent triggering of other events when closing a JPopupMenu by clicking outside it?

There are some properties of the right-click context menu I would like to replicate with a JPopupMenu: When menu is open and you click elsewhere, menu closes. When menu is open and you click elsewhere, nothing else happens. I've got the…
BCarpe
  • 860
  • 10
  • 27
6
votes
7 answers

How to prevent a disabled JMenuItem from hiding the menu when being clicked?

In my Java swing application i have noticed that when i click on a disabled JMenuItem in a JPopupMenu it hides the menu, but i i do not want to hide it, as if nothing is clicked. Is there a way to prevent this ? ----------------------------------->…
Brad
  • 4,457
  • 10
  • 56
  • 93
6
votes
2 answers

Find the JTable row on which a popup menu has been invoked

I have a JTable and a popup menu that is specific to each row. I want to calculate the row on which the user right-clicked his mouse (Windows L&F) to bring up the popup menu. I create a MouseListener for the table, so it gets the MouseEvent at the…
user492820
  • 61
  • 1
  • 1
  • 2
6
votes
2 answers

Programmatically expand sub JMenuItems

I would like to programmatically expand a particular JMenuItem in a JPopup. For example in the code below import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JFrame; import…
Jamesy82
  • 369
  • 3
  • 10
6
votes
4 answers

How can i make a JPopupMenu transparent?

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 { …
nathan
  • 1,111
  • 3
  • 18
  • 33
5
votes
3 answers

Right-click MouseListener on whole JTable component

I'm using Netbeans and I've designed a window with JTable and added MouseEvent listener on JTable component and added this code: private void productsTableMousePressed(java.awt.event.MouseEvent evt) { if(evt.isPopupTrigger()) { …
5
votes
3 answers

How to get the dimension of a JPopupMenu?

I have a TrayIcon with a JPopupMenu attached to it. When I add a JMenuItem to the popup menu, I want to know the dimension of this popup menu. But the dimension is not calculated: getBounds(), getSize() and getVisibleRect() all return zero-by-zero…
MC Emperor
  • 22,334
  • 15
  • 80
  • 130
5
votes
1 answer

Why isn't componentHidden called for my JPopupMenu?

I want to be notified when my JPopupMenu is hidden — whether because an item was selected, the menu was dismissed, or setVisible(false) was called on it. Here is my test code: import javax.swing.*; import java.awt.*; import…
heycam
  • 2,188
  • 15
  • 19
5
votes
1 answer

JTable copy and paste using Clipboard and AbstractAction

When I try to paste into a JTable cell using table.setValueAt(), the cell I am pasting in remains blank, but setValueAt() seems to be working. Also, when I try to cut or copy from one cell, the Paste option on my JPopupMenu remains disabled when I…
stevetronix
  • 1,231
  • 2
  • 16
  • 32
5
votes
4 answers

getting right click location from popmenu action event

I have a java program that opens a popup menu when right clicked in a JPanel. When any of the popup menu items are clicked, I want to print the location of the right click that triggered the popupmenu in the terminal. How do I do this? How do I get…
user1868856
  • 113
  • 2
  • 5
5
votes
1 answer

JTree rightclick behaviour like in any Filebrowser

I am trying to implement a JTree to represent a database! The Root is the database, which can have several relations. Each relation can have attributes and functional dependencies. Each node (database, relation, attribute and fd) has a different…
Andreas Freitag
  • 357
  • 1
  • 7
  • 20
4
votes
1 answer

Modify JPopupMenu/JMenuItem look and feel

I am trying to create a custom JPopupMenu that has a different color and rounded borders. I tried the following code but there had been no changes to the way the PopupMenu look. JButton button = new JButton("Test"); button.addActionListener(new…
Cherple
  • 725
  • 3
  • 10
  • 24
1
2
3
16 17