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

JPopupMenu not showing text of JMenuItem

I'm trying to create a JPopupMenu, but for some reason, it doesn't show the text I've set on the JMenuItems. The menu itself works, there are menuitems in it and they are responsive, but the text is not showing. I'm creating the menu like…
Tobi
  • 5,499
  • 3
  • 31
  • 47
0
votes
1 answer

How to make a JPopupMenu in java with an item to copy text

I want to know how to make a JPopupMenu that has an item to copy text. I have started with putting the label with a JPopupMenu. What is the code for this item "Copy" in the JPopupMenu to copy the text?
The1Dev
  • 27
  • 6
0
votes
1 answer

JPopupMenu and JMenuItem general usage

I have a simple question; I am trying to add a menu to my program. This is what I have thus far: public static void main(String args[]){ try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch…
Huang Lee
  • 53
  • 4
0
votes
1 answer

How to access MouseEvent getX()/getY() from JPopupMenu?

I have a popupmenu like this final JPopupMenu contextMenu = new JPopupMenu(); final JMenuItem addTask = new JMenuItem("Add Task"); Then i add a MouseListener: component.addMouseListener(new MouseAdapter() { @Override public void…
MS1
  • 508
  • 9
  • 23
0
votes
0 answers

SetLabel doesn't work on a JPopupMenu

For me the setLabel method of the java's JPopupMenu does not work. Here is a simple popup menu example: http://www.java2s.com/Code/Java/Swing-JFC/AsimpleexampleofJPopupMenu.htm Inside is: public JPopupMenu popup; popup = new…
taalf
  • 179
  • 1
  • 10
0
votes
2 answers

error on jMenuItem.addMouseListener(this)

I tried to add a actionlistener to my JMenuItems for my right click. I seen many example they use item.addActionListener(this) to add a listener to the JMenuItem JMenuItem item; item.addActionListener(this); But however I tried it out and I am…
user2211678
  • 669
  • 8
  • 13
  • 24
0
votes
1 answer

Swing - How to add a JPopupMenu in a JTable Cell

I'd like to insert a JPopupMenu for each cell of a column of my JTable (to be able to select multiple items). Any idea how to do that?
TzL
  • 13
  • 3
0
votes
0 answers

How to set the JMenuItem's PopupLocation

As the title says, I need to manually set the popup location of the JMenuItem. jMenuItem1.getPopupLocation(null).setLocation(null); I tried the above, but I can't proceed because it gives me compile errors. I think it is with the "null" values.…
Sniper
  • 41
  • 7
0
votes
2 answers

Center JLabel within JPopupMenu

I know this is me being completely ocd, but I am having an issue centering the JLabel text within the JPopupMenu. I've tried popup.add(new JLabel("Menu",JLabel.CENTER)); and label.setHorizontalAlignment(SwingConstants.CENTER);…
Simon Rubin
  • 198
  • 11
0
votes
0 answers

Showing a JPopupmenu then selecting a JButton requires 2 clicks

It seems after showing a JPopupmenu using the show() method it requires 2 clicks to select a JButton or any component with a ActionListener attached to it; one click for the popup menu to disappear and another to be actually detected by the…
Sammy Guergachi
  • 1,986
  • 4
  • 26
  • 52
0
votes
2 answers

Starting mouse drag when JPopupMenu is open?

I have a popup menu that opens on mouse hovering on a component. Now I want to be able to start dragging the component while the popup is still open, but the popup menu close event always consumes the first mouse click. Is there a workaround for…
Stephan
  • 4,395
  • 3
  • 26
  • 49
0
votes
2 answers

Swing - Changing different JLabels with the same Component Popup menu

I am pretty new to Swing, any help appreciated. I have the following situation: A "Main" Class where I define my main JPanel and default Label text. A "GUILabel" Class (extends JLabel) where I define the look of the Text Labels. A "popupmenu" Class…
user3238620
  • 33
  • 1
  • 5
0
votes
0 answers

Adding a JPopupMenu to an array of JCheckBoxes

I am trying to add JPopupMenu (on right click) to an array of check boxes and am doing it in below way: JPanel Pane = new JPanel(); Pane.setLayout(new BoxLayout(Pane, BoxLayout.PAGE_AXIS)); m_popMenu = new JPopupMenu(); JMenuItem item = new…
user3164187
  • 1,382
  • 3
  • 19
  • 50
0
votes
1 answer

Adding a JScrollPane to JPopupMenu

I'm trying to add a JScrollPane with a custom component in it to a JPopupMenu. It works perfectly, it also shows the vertical scroll bar when needed. But when I try to scroll using the mouse wheel, the popup menu disappears. Anybody got an idea? (If…
trainrobbery
  • 500
  • 3
  • 14
0
votes
1 answer

Java popupmenu in Netbean GUI selectall action

Below is my mouse event code for the clicking action. However this action doesnt work for me. How should i change this to work? private void menuSelectallMouseClicked(java.awt.event.MouseEvent evt) { …
BeyondProgrammer
  • 893
  • 2
  • 15
  • 32