JPopupMenu « Menu « Java Swing Q&A





1. JPopupMenu Behavior    stackoverflow.com

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 ...

2. How to animate showing of JPopupMenu?    stackoverflow.com

I'd like to show increasingly more of a JPopupMenu so it appears to "slide out". It's not for menu items, where animation doesn't make too much sense. Instead it's for a ...

3. JPopUpMenu problem with adding menu items    stackoverflow.com

I'm creating JPopUpMenu with following code:

JPopupMenu popup1 = new JPopupMenu();
JPopupMenu popup2 = new JPopupMenu();

JMenuItem freeze = new JMenuItem("freeze");
freeze.addActionListener(new FreezActionListener(this));

JMenuItem unfreeze = new JMenuItem("unfreeze");
unfreeze.addActionListener(new UnFreezActionListener(this));

JMenuItem sortU = new JMenuItem("sort");
JMenuItem sortD = new ...

4. How to create a JButton with a menu?    stackoverflow.com

I want to create a Toolbar for my application. If you click a button on that toolbar , it will pop-up a menu , just like the toolbar of eclipse. I don't ...

5. Why isn't componentHidden called for my JPopupMenu?    stackoverflow.com

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 ...

6. JTabbedPane tabs    stackoverflow.com

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 ...

7. Java: Show JPopupMenu without passing an invoker component    stackoverflow.com

When I let popup a JPopupMenu without passing the "invoker component", the menu doesn't work: submenu's don't open and isn't getting repainted. But when I create a completely useless JFrame with ...

8. One jPopup for several controls    stackoverflow.com

I have code like this:

    jTextArea1.add(jPopupMenu1);
    jTextArea1.setComponentPopupMenu(jPopupMenu1);

    jTextField1.add(jPopupMenu2);
    jTextField1.setComponentPopupMenu(jPopupMenu2);
and for menu items I have actions:
private void CopyActionPerformed(java.awt.event.ActionEvent evt) {
 ...

9. JPopupMenu is not working    stackoverflow.com

I wrote a simple program to understand how JPopupMenu works. But something is wrong with my code it doesn't show popup menu correctly. Please can someone tell me the reason?

public class ...





10. Destroy a JPopupMenu in Java Swing    stackoverflow.com

I'm using a JPopupMenu displayed when I do a right click on certain components in my GUI. Now I have to destroy the popup menu displayed in this 2 situation:

  1. The user ...

11. Using visual swing JPopup menu in netbeans    stackoverflow.com

i want to add a popup menu to my app but when i add it to my panel i see its disappear. how i can edit jpopup menu visualy like other menus? ...

12. JPopupMenu not appearing?    stackoverflow.com

I have a Java applet that will consist of several popup menus that the user will have to interact with. However, the JPopupMenu won't show up when added. Here is my ...

13. JPopupMenu Behavior OSX 10.6.7    stackoverflow.com

My problem is when i right click on the JFrame. JPopupMenu show up but if i click anywhere outside the JFrame the menu does not disappear. I have to click somewhere ...

14. Modal / Thread blocking JPopupMenu?    stackoverflow.com

I'd start by saying that I'm not looking for a modal JDialog with a menu-like implementation. My question is about code flow and code readability / maintainability in swing consider this code:

print("A");
int option ...

15. Problem trying to Create a JPopupMenu with Netbeans wizard    forums.netbeans.org

Hello Everybody, as we know Netbeans has a wonderful wizard where you can do your GUI easily, but I have create one with it. You can see it.. Attached files. And ...

16. Display a JPopupMenu in a JApplet    coderanch.com





17. Unrelenting JPopupMenu    coderanch.com

I have a JPopupMenu that appears in various places on the desktop. If it comes up as a result of right clicking an icon, I want that menu to become invisible if the user clicks off the menu. The trouble is that it stays up unless a menuitem is selected. This causes no end of interference with other popup menus that ...

18. JPopupMenu    coderanch.com

Try to use MouseListener on components somewhereInTheInitiationOfTheObject() { ... popupListener = new PopupListener(); // defined later ... } void addMouseListenerToAllComponents(Component[] comp) { if (comp != null) { for (int i = 0; i < comp.length; i++)
{
comp[i].addMouseListener(popupListener);
if (comp[i] instanceof Container)
{
Component[] subcomp = ((Container) comp[i]).getComponents();
addMouseListenerToAllComponents(subcomp);
}
}

19. JPopupMenu    coderanch.com

I'm using JPopupMenu in my application to show the right-click popup menu.I'm doing it like this: popupMenu.show(e.getComponent(),e.getX(),e.getY()); The popup menu shows at that point and all popupmenu items appear below that point. This causes problems when i right-click at the bottom of my screen. Here some of the popupmenu components become invisible. So, i need a way to display the popup ...

20. JPopupMenu on top    coderanch.com

Hi! Is there any way to make my popupmenu displayed always on top of all panels? Now I have two panels and the left panel is invoker and if my popupmenu appers right next to another panel it wont be displayed completely but "under" right panel. edit: some user stupidity approaching :| [ July 15, 2002: Message edited by: Martin Schneider ...

21. Difficulties with JPopupMenu    coderanch.com

Hi all, I am implementing a right mouse menu for an application I am working on. I have a mouse listener attatched to my JTable, and when the user clicks the right mouse button it calls this method: public void setupRightMouseMenu(MouseEvent e){ JPopupMenu rmenu = new JPopupMenu(); rmenu.setLightWeightPopupEnabled(false); rmenu.setBorderPainted(true); rmenu.add(menuItemFactory("Copy","copy","copy")); rmenu.add(menuItemFactory("Edit","edit","paste")); rmenu.add(menuItemFactory("Export","export","s_recall")); rmenu.add(menuItemFactory("Print","print","s_print")); if( !archive ){ rmenu.addSeparator(); rmenu.add(menuItemFactory("Replace","replace",null)); rmenu.add(menuItemFactory("Archive","archive",null)); } rmenu.pack(); ...

22. Navigating menu hierarchy in a JPopupMenu    coderanch.com

Hi all, I'm trying to use one ActionListener for a large popup menu which can be dynamically modified by my customer classes; i.e., I don't necessarily know in advance what will be in there. I can, however, ensure that I get an actionPerformed on each of those menuitems. So, in my actionPerformed, I'm trying to figure out how to navigate the ...

23. JPopupMenu difference between 1.3 and 1.4.1?    coderanch.com

Hi all, While testing a swing app I've been previous running inside JDK 1.3 (in JBuilder), I've come across what seems to be a serious behavioral difference in JPopupMenu... My app is building a look-alike of the Windows Start Menu, which consists of a JPopupMenu with a bunch of submenus and menuitems and whatnot; and as part of this I also ...

24. Shadow on JPopupMenu    coderanch.com

25. JPopupMenu Questions    coderanch.com

26. A serious JPopupMenu Problem Help!    coderanch.com

Hi Hope u all r fine . I had a solution from ur side few months ago i m really thankfull to u for that. Now i m facing a few problems with the JPopupMenu and JMenuItems. The problem is the we delveloped a large scale application using VisualAge for Java. The application was menu driven , having all the options ...

27. JTextFiled and Jpopupmenu    coderanch.com

28. Using HTML with JPopupMenu    coderanch.com

Hi. I guess this is maybe more of an HTML question. I was hoping someone could help me out with. Rather than going through the headache of displaying a JTable off of a popup menu , I decided to use HTML and create a table. It works great, however I can't seem to get the spacing correct on it. I have ...

29. JPopupMenu    coderanch.com

30. JPopupMenu doubt    coderanch.com

hello guys, I need a help in performing the following task. I need to create a popup menu in swing ,in that if i select a field then the file open window should be opened. I know there is a class named JpopupMenu in swing.But i didn't use it.Can i find some examples for that.And similarly for opening the file open ...

31. Problem in Opening JPopupMenu    coderanch.com

I made up this test program and it does not exhibit the behavior you describe. // import java.awt.*; import java.awt.event.*; import java.util.Random; import javax.swing.*; public class MenuTest extends JApplet { public void init() { JButton launch = new JButton("launch child"); launch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { launchChild(); } }); JPanel north = new JPanel(); north.add(launch); ...

33. How to make JPopupMenu stay open?    coderanch.com

34. JPopupmenu    coderanch.com

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

35. JPopupMenu - Help required    coderanch.com

36. regarding JPopupMenu    coderanch.com

37. JPopupMenu    coderanch.com

38. In what way can I avoid disapperaing the item of JPopupMenu?    coderanch.com

JPopupMenu popup = new JPopupMenu(); JMenu menu = new JMenu("Menu1"); JPanel aPane = new JPanel(); aPane.add(new JLabel("Enter time:")); try{ MaskFormatter formatter = new MaskFormatter("##:##"); formatter.setPlaceholder("#"); JFormattedTextField time = new JFormattedTextField(formatter); aPane.add(time); } catch(ParseException ex) { return; } aPane.add(new JLabel("Choose the name")); aPane.add(new JComboBox(new String[]{"Ann","Kat"})); aPane.add(new JButton("OK")); menu.add(aPane); popup.add(menu); JMenuItem item=new JMenuItem("other item menu"); menu.add(item); popup.add(menu); popup.show(e.getComponent(), 100,100);

39. JPopupMenu - bug?    coderanch.com

package musicwizard.gui; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.PopupMenu; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.UIManager; import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import musicwizard.utilities.MusicUtilities; public class JMenuCollapseCatch { public static void main(String[] args) { JFrame f = new JFrame("This is a test"); Container content = f.getContentPane(); Dimension frameSize = new Dimension(200, ...

40. How Dynamic JPopupMenu in swing?    coderanch.com

41. JPopupMenu and full screen, Mac OS 10.4    coderanch.com

All, Ok, first off, I should probably ask if there's any good forums that anyone knows of that specific to Java development on Macs - there appear to be some, ah, shall we say, "interesting" quirks with Java on a Mac. That said, I'm having this particular issue. I have a class that extends JPanel. At one point, when the user ...

42. JPopupMenus    coderanch.com

Hi everyone, I have registered a JTextField to a KeyListener class that causes a JPopupMenu to appear when certain letters are typed into the textfield. I want to be able to just carry on typing if I don't want to choose any of the options on the menu, but at the moment I have to manually click the focus back into ...

43. JPopupMenu question    coderanch.com

44. two jpopupmenus associates with two differents components    coderanch.com

thank for the reply yeah i should have think about this but i didnt lol im use to do event.getsource() with actionlistener but i never done it with a mouselistener() now its more clear how to do this thank again michael here is the solution : import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DemoPopupMenu extends JFrame { JPopupMenu popupMenu,pop; JMenuItem ...

46. JPopupMenu and ActionEvents    coderanch.com

public class RemoveRowTablePopup extends PopupMouseHandler { private JMenuItem deleteRow; SKTable table; private JPopupMenu menu; ActionListener tpl; public RemoveRowTablePopup(SKTable table) { this.table = table; //TablePopupListener tpl = new TablePopupListener(); menu = new JPopupMenu(); // Delete row menu item. deleteRow = new JMenuItem("Delete Row(s)"); // Add items to menu. // Add seperator menu.add(new JSeparator()); // Add Delete menu menu.add(deleteRow); this.setMenu(menu); } public void ...

47. How to make JPopupMenu invisible?    coderanch.com

48. show and hide a JPopupMenu    coderanch.com

This seems like it should be really simple but I just can't get it to work. I want a JPopupMenu to appear when the user clicks on a button. I then when the menu to disappear when the user clicks anywhere other than on the menu. The only problem I've got is that I'd like the same to happen when the ...

50. Combine two different JPopupmenu    coderanch.com

My code below displays only the menu item from pop2. Any idea ? import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.border.BevelBorder; import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; public class PopupMenuExample extends JPanel { /** * */ private static final long serialVersionUID = 1L; public JPopupMenu popup; public JPopupMenu popup2; public JPopupMenu ...

51. Resizable JPopupMenu    coderanch.com

52. showing/hiding JPopupMenu having JButtons as its elements    coderanch.com

Hi Friends my requirement is I have a JButton and on clicking it, a JPopupMenu will be opened whose menu elements are JButtons. Upto this I am fine. Now, When I click on one of the menu element JButton, I need some other menu to be opened. When this second menu is opened, the first menu should stay opened. I am ...

53. JPopupMenu    coderanch.com

Hi guys (not meant in chauvinistic fashion), I got something like a "dynamic JPopupMenu" (i call it dynamic because it changes its size depending on the size of a Jlist). My problem is that, the JList it gets its data from is empty in the beginning, thus the Jpopupmenu is not displayed (or just a small fraction of it), when right ...

54. JPopupMenu problem    java-forums.org

public class JOrderPopupMenu extends JPopupMenu implements ActionListener{ private JMenuItem mniMemo; private JMenuItem mniNosRef; public JOrderPopupMenu(){ mniMemo = new JMenuItem("Memo"); mniNosRef = new JMenuItem("No_Stock_Referentie"); mniMemo.addActionListener(this); mniNosRef.addActionListener(this); JCheckBoxMenuItem test = new JCheckBoxMenuItem("test"); add(mniMemo); add(mniNosRef); add(test); } public void actionPerformed(ActionEvent e) { System.out.println("actionPerformed"); if( (JMenuItem)e.getSource() == mniMemo){ System.out.println("mniMemo"); } else if ((JMenuItem) e.getSource() == mniNosRef){ System.out.println("mniNosRef"); } } }

55. Listening to JPopupMenu invocation    java-forums.org

56. JPopupMenu not hiding    java-forums.org

JPopupMenu not hiding Hi there i need help in my code, jpopupmenu is not hiding and i dont how to do it Can anyone help me Java Code: package T; import java.awt.AWTException; import java.awt.Component; import java.awt.Font; import java.awt.Image; import java.awt.MenuItem; import java.awt.SystemTray; import java.awt.Toolkit; import java.awt.TrayIcon; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import ...

57. dynamising the height of a JPopupMenu    java-forums.org

how can we dynamise the height of JPopupMenu in order to contain the full text-message from a JLabel, ie, a JLabel containing some long text messages is shown inside a JPopupmenu of a fixed width.so, i want that the text should automatically fit to its width go to another line downwards to the dynamically generated height. Need ur valuable help.Thanks.

58. JPopupMenu falls behind window    java-forums.org

hello, i seem to be having some trouble here. I am writing a little class that is a popupSlider widget. The class extends JLabel so the user would treat this component like a label. When the label is left clicked on a jpopupMenu with a slider in it appears. This works all well and good except the second i click on ...

59. JPopupMenu    java-forums.org

60. JPopupMenu not responding    java-forums.org

Hi Java fans, I have a pickle situation. So I have this RightClickMenu object which extends JPopupMenu. Java Code: package GUI; import javax.swing.*; public class RightClickMenu extends JPopupMenu { private final static JMenu set_stage = new JMenu("Set Stage"); public RightClickMenu() { super(); JMenuItem set_warranty = new JMenuItem("Set Warranty"); JMenuItem print_ber = new JMenuItem("Print BER"); JMenuItem print_documentation = new JMenuItem("Print Documentation"); JMenuItem ...

61. ChartPanel JPopupMenu problem    jfree.org

I'm having a problem with the JPopupMenu in the ChartPanel I only want to show the scaling part of the popup-menu so I have made this code: chartPanel.getPopupMenu().remove(0); chartPanel.getPopupMenu().remove(1); chartPanel.getPopupMenu().remove(2); The problem is that the JPopupMenu is still showing the "divider" lines that was separating the three items. So that the menu looks weird in the top.. How to remove these ...

62. Creating a new instance from JPopupMenu doesn't work    forums.oracle.com

-- If I take MySQLMyPhoneBook.class out of the dbtest package folder, and compile/run the SystemTrayApp, it runs and doesn't complain when I click on my button which calls MySQLMyPhoneBook.class. --- So, you're saying that if you delete the MySQLMyPhoneBook.class file, your program runs correctly? Post the code for your no arg constructor in MySQLMyPhoneBook. Also, post the package statement in each ...

63. Horizontal JPopupmenu    forums.oracle.com

Sorry I don't know how to do it off the top of me head. But out of interest, why do you want it? I have been doing GUIs for years now and have never seen a horizonatal popup menu, so it is quite non standard. That doesnt mean you shouldn't do it but I would be wary of it. Users like ...

64. onfoucs JPopupMenu show line on the top    forums.oracle.com

65. Netbeans and JPopupMenu    forums.oracle.com

Im having a problem creating a JPopupMenu, Im using the netbeans GUI builder, I've added the popup menu to the Jframe, and can get it to display itself when right clicked, however i cannot get it to hold any components. I tried adding a menu item to it, first by dragging and dropping, which did not work, then by right clicking ...

66. JPopupMenu    forums.oracle.com

hello. I am looking to create a simple pop-up menu for users to build up a chord from. ie, the first menu has options Ab, A, Bb, B, C, Db etc and when the mouse lingers on one of these a submenu pops up M, m, dim, aug, ALT etc and again 6, 7, maj7, min7 etcetc. I was just wondering ...

67. Problem with JpopupMenu    forums.oracle.com

68. Strings setFont JPopupMenu    forums.oracle.com

Hi, I am creating a popup menu using JPopupMenu. I am filling the popup menu with some string contents. While doing so, I am trying to format it with some specific fixed font type like courier so that I can neatly display the popup menu with some formatting. I am not able to use setFont method as it is not defined ...

70. Memory Leak with JPopupMenu    forums.oracle.com