Popup menus over elements in a JList

Hi,
How would I create a Popup menu when I select an element in a single selection only JList?
Is it possible to have the popup show on any selection event (keyboard, mouse, or even by programatically causing an element to be selected)?
thanks.

I kind of got the behavior I want with doing following, but when I try to use this approach in an Applet, I get an ugly Java Applet Window message:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MenuTest extends JFrame implements ActionListener{
DefaultListModel lm = new DefaultListModel();
JList list = new JList(lm);
JScrollPane scroll = new JScrollPane(list);
JPanel p = new JPanel(new BorderLayout());
JPopupMenu popup = new JPopupMenu();
JMenuItem menuItem;
public MenuTest(){
     list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     lm.addElement("one");
     lm.addElement("two");
     lm.addElement("three");
     lm.addElement("four");
     getContentPane().add(p, BorderLayout.CENTER);
     p.add(scroll, BorderLayout.CENTER);
     menuItem = new JMenuItem("print to stdout");
     menuItem.addActionListener(this);
     popup.add(menuItem);
     list.addMouseListener(new MouseAdapter(){
          public void mouseReleased(MouseEvent e){
          int index = list.locationToIndex(e.getPoint());
          if (index>-1&&!(list.isSelectionEmpty())){
               popup.show(e.getComponent(), e.getX(), e.getY());
     addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
public void actionPerformed(ActionEvent e){
     System.out.println((String) list.getSelectedValue());
public static void main(String args[]){
     MenuTest window = new MenuTest();
     window.setTitle("MenuTest");
     window.setSize(200, 300);
     window.setVisible(true);
It seems the behavior is different than for frames and in my GNOME desktop manager when I run my applet it opens a new window for the PopupMenu.
If anyone has run into this and has a work around please let me know.
thanks

Similar Messages

  • Making popup menus stop painting over the current window

    I'm making up a game that relies on a regular menu bar for it's menus. But for some reason the drop-down menus insist on rendering themselves over the current window instead of creating a new object over it like it should. This causes them to vanish right after opening because the game is constantly refreshing the area it paints over, but if I reduce the window drastically in a way there's no room to paint the drop-down menus over the existing area, they appear normally because a new window is created to display them.
    How do I ferce it to always create a new window?

    Jack Mcslay wrote:
    I'm making up a game that relies on a regular menu bar for it's menus. But for some reason the drop-down menus insist on rendering themselves over the current window instead of creating a new object over it like it should.No it shouldn't, and your saying so doesn't change anything.
    This causes them to vanish right after opening because the game is constantly refreshing the area it paints over,... implying that you have a wrong approach to custom painting
    but if I reduce the window drastically in a way there's no room to paint the drop-down menus over the existing area, they appear normally because a new window is created to display them.As expected
    How do I ferce it to always create a new window?Wrong question. Ask how to perform custom painting correctly -- which is answered in the tutorial suggested twice.
    db

  • Popup Menus from Fireworks to Dreamweaver

    I have created popup menus in fireworks and imported the html
    into Dreamweaver. But when I do the table cell resizes to the
    menu's expanded size. How can I get it to only take space of the
    unexpanded button. Where when expanded the dropdown flows OVER the
    underlying page.
    Desparately seeking help-
    Bobbi Jo

    Post a link to the page, please.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "BobbiJo1" <[email protected]> wrote in
    message
    news:e26n71$c6h$[email protected]..
    >I have created popup menus in fireworks and imported the
    html into
    >Dreamweaver.
    > But when I do the table cell resizes to the menu's
    expanded size. How can
    > I get
    > it to only take space of the unexpanded button. Where
    when expanded the
    > dropdown flows OVER the underlying page.
    >
    > Desparately seeking help-
    > Bobbi Jo
    >

  • Fireworks 8 PopUp menus-

    I create a page with single level popup menus in FW8. Export
    html/slices to DW8
    The menus only show up when I do a mouse over. I can modify
    the code in DW8 to remove the javascript onmouseover= ( ... ), and
    add a onload=(..). All then works as I want it to work. Top menu
    displayed on page load, mouse over/out behavior works as expected.
    The top level menus are acting like I would expect the lower
    level popups to work. Mouse over to display. Mouse out, timer
    delay, they go away.
    I assumed/want the first level menus should display on page
    load. Just the popups (lower menu levels) should popup with
    mouseover. Wrong assumption or something wrong?? I guess I could
    use Buttons instead.
    Insight????

    Check the uberlink and McFly tutorials at PVII
    http://www.projectseven.com/)
    and the Navbar tutorial at Thierry's place (
    http://www.tjkdesign.com)
    Either of these are miles better than any DW/FW pop-up
    menu....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "borisbsp" <[email protected]> wrote in
    message
    news:e5pg36$nfb$[email protected]..
    >I would prefer a workaround to this problem (Since the
    money is spent on
    >the
    > software). However I will entertain other solutions as
    long as they can
    > provide me with the same design out come.
    >
    > The verticle popup menus need to be triggered by gif or
    jpeg images like
    > this:
    >
    > <a target=_blank class=ftalternatingbarlinklarge
    > href="
    http://www.eiptuning.com/eip/images/forum/navigation_01.jpg">Screen
    > Shot
    > Example</a>
    >
    > If you have some solutions that fit this criteria, and
    it doesn't mean
    > that I
    > have to reinvent the wheel, I would be interested.
    >
    > Thanks,
    > Boris
    >

  • Popup Menus and Flash

    Hi All,
    I have created a you-beaut pop-up menu in Fireworks 8 and
    have it sitting on the webpage just nicely however, on the page is
    a Flash slideshow as well. The Popup menus are hidden behind the
    Flash content
    Now I have read all the stuff about making wmode transparent,
    but it makes no difference.
    Has anyone else come across this problem and found a
    solution?
    Thanks all.

    > which is probably why Murray is a little reserved about
    this animal.
    > But, it works for me.
    A little reserved? I'm rabidly opposed to it. A menu system
    that can
    generate > 3000 lines of css should be thrown in the
    toilet. I don't pick
    that number lightly - it was actually on a menu that was
    posted here for
    help not too long ago. Personally, I think you made a bum
    decision - all my
    experience is recoiling at this choice.,...
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "WollombiWombat" <[email protected]> wrote
    in message
    news:[email protected]...
    > As they say in the classics - Life's a bugger.
    >
    > I just posted a nice reply to this thread, and on the
    upload it got dumped
    > so
    > at the risk of repeating myself I will try again.
    >
    > Murray: Many thanks for the suggestion to take a look at
    the PVII options.
    > I
    > had not considered them as I was looking for a drop-down
    menu gizmo that
    > would
    > appear on top of Flash content. It is worth mentioning
    that I have indeed
    > used
    > many PVII solutions over the years. Thank Al !!
    >
    > So, I decided to take a close look at the solution
    SugnaShane proposed
    > using
    > SWFObject and Son of Suckerfish. To cut a long story
    short - that did not
    > work
    > either. That had me baffled for about an hour then the
    penny dropped !!!
    > Turns
    > out I had not read the fine print in SugnaShane's code
    example which is
    > different to the current practice as presented by the
    author of SWFObject,
    > Geoff Stearns at
    http://blog.deconcept.com/swfobject/
    >
    > What SugnaShane had shown in his example was an
    implementation based on
    > the
    > earlier iteration of SWFObject which when current was
    called FlashObject.
    > So,m
    > when I changed my code to reflect the application of
    FlashObject instead
    > of
    > SWFObject the drop-down menus appeared on top of the
    Flash content on my
    > webpage.
    >
    >
    - YOU LITTLE RIPPER SUGNASHANE
    >
    > In conclusion, I reverted back to the Fireworks popup
    menu code as it gave
    > me
    > what I was looking for quickly and easily. Along the way
    I discovered a
    > few
    > gotchas which is probably why Murray is a little
    reserved about this
    > animal.
    > But, it works for me.
    >
    > Many thanks again to all concerned. The "Work in
    progress" can be seen
    > here:
    >
    http://wollombi.wollombivalley.com/
    >

  • Popup menus getting cut off...

    I'm writing an applet, using Swing, which is contained within a small pop-up browser window. Within my applet i'm using a number of popup menus.
    The problem is in certain situations, when the pop-up menu is very wide, its gets cut off by the sides of the browser window. However when the pop-up menu is very tall and extends past the bottom of the browser window, the menu appears over the top of the window and so isn't cut off.
    So its clear that a pop-up menu can extend outside of the browser window, but i need to make it so it will do this when the menu is to wide, not just when it is too tall. I thought it might have something to do with menus being lightwieght components by default, so I tried using setLightWeightPopupEnabled to force the menus to be heavywieght, but this didn't seem to help.
    Anybody got any ideas on this?

    no, cuz if it extends outside the applet or frame, it usually uses a Window as the root popup container, so it shouldn't do that.

  • Popup menus in Forms 10g and Java Bean

    Hi all.
    What class in Java corresponds with popup menus(not in menu module) ?
    I know that oracle.ewt.lwAWT.lwMenu.LWPopupMenu is corresponds with MenuBar's submenu. I can find Buttons, Text Fields, Menu and other components in my Form-Applet, but I don't know how to find popup menus in forms through Java Bean...

    Hello François,
    I have created a java bean that dynamically creates a popup by left-clicking on the bean.
              Set_Custom_Property( 'BLOCK.BEAN', 1, 'ADD_ITEM', 'Item' ) ;
              Set_Custom_Property( 'BLOCK.BEAN', 1, 'ADD_SEPARATOR', '' ) ;
              Set_Custom_Property( 'BLOCK.BEAN', 1, 'ADD_ITEM', 'Item one' ) ;     
              Set_Custom_Property( 'BLOCK.BEAN', 1, 'ADD_ITEM', 'Item two' ) ;
    My problem is the layout. I want to simulate a button. I can't put the bean transparent over a button and I can't simulate a button with the bean.
    How can I add the popup functionality to a button and not only to the bean? Or any other workaround?
    Regards Pedro.

  • How to control Popup Menus

    Hello there,
    I have little problem controlling my popup menus, I need to have one menu item in the popup menu when I put the mouse on the top of a selected area. If mouse clicked on the selected area then I need to add more menu items. Here is my code so please help if you can.
    public void mousePressed(MouseEvent me) {popupmenus(me, true);}
    public void mouseReleased(MouseEvent me) {popupmenus(me, true);}
    public void mouseMoved(java.awt.event.MouseEvent me){
    popupmenus( me, false);
    public void popupmenus(java.awt.event.MouseEvent me, boolean pop)
    xpos = me.getX();
    ypos = me.getY();
    System.out.println(pop);
    if (xpos > rect1xco[0]&& xpos < rect1xco[0]+rect1width[0] && ypos >
    rect1yco[0] && ypos < rect1yco[0]+rect1height[0])
    if(pop==true)
    ar[0].add(it[0]);
    ar[0].add(it[1]);
    System.out.println("true");
    rect1Active[0] = true;
    ar[0].add(it[2]);
    ar[0].show(this,xpos,ypos);
    else
    rect1Active[0] = false;
    Thanks for your help.

    What is your particular problem?
    I see two things that may be issues...
    1) you do the same thing on mousePressed and mouseReleased. This means that if you click on the selected area, it will add the items twice.
    2) mouseMoved also seems to add an item, meaning that every registered event in the rectangle will continue to add the same item over and over.
    If neither of these are your problem, please share what you need help with.
    -JBoeing

  • How can i change the order of  elements in a JList ?

    Hi,
    i would like to know if it is possible to change the order of elements in a JList ? Maybe i could use drag and drop to do this ?
    Thanks for answering.

    The simplest way is probably to implement ur own listmodel and then supply the listitems in the order u want. Example:
    class MyListModel
              extends AbstractListModel
              implements ContactListListener {
    public int getSize() {
    return listitemcount;
    public Object getElementAt(int index) {
    //here u return the item for the index at the list
    //if u for example have an array of strings
    //which u wanna have listed in reversed order (reversed to
    //the order in the array, u could do
         return myarray[getSize()-index];
    }

  • Can I turn off the onscreen popup MENUs in safari 6.0.5? (mountain lion

    Not popup windows or popup ads.  I'm referring to the system popup menus that appear mid-screen when using Safari.  The menus appear to be contextual, and will have choices, such as "go back."  I have to tap somewhere on the screen to get it to go away.  Frankly, I'm not even sure what tackpad gesture I am doing to cause them to pop up.  I only want to use the regular tool bar menu and I find the popup menus disruptive and annoying.  I have not been able to find a preference that relates to them.  Can I get rid of these things?  Thanks for your help...
    Jen

    I tried that, but there are no settings in there regarding the pop up onscreen menus.  It seems to happen in other apps, though less frequently than Safari.  Maybe it is an OS thing?  However, I could not find any applicable preference...

  • ANN Half-hour webinars (free): Hypertext in FM Generated Files (Apr 4)+Popup menus in PDFs (Apr 11)

    (free; no fluff, no hype, no nonsense; starting 9am PT)
    Hypertext in FrameMaker Generated Files (TOC/IX) -- Thursday, April 4
    For more info or to register: https://www3.gotomeeting.com/register/474393614
    Popup menus in PDFs (with FrameMaker-to-Acrobat TimeSavers + Navigation Asst)
    -- Thursday, April 11
    For more info or to register: https://www3.gotomeeting.com/register/114620830
    Shlomo Perets
    MicroType, http://microtype.com
    FrameMaker/Acrobat/Captivate training & consulting * FrameMaker-to-Acrobat TimeSavers/Assistants

    Well, I made it to the Apple store and they, contrary to the guys at B&H, confirmed my original suspicion and yours: that the drive was failing.  I bought a replacement drive and am restoring my time machine back up now. 
    I am a bit annoyed that the B&H guys got this one wrong but I have to give them credit for underselling me rather than overselling me; I do appreciate that.
    Also worth mentioning is that the 3TB Seagate drive was less than 2 years old and is supposedly still under warrantee.  I am looking forward to seeing what kind of support I get from them. 
    So big thanks to you, Bob, for your very good suggestions.   The Apple community has come through strong for me and I appreciate it.

  • Popup Menus in Forms 10g

    I have a tool bar that I added within a Form that has few popup menus...
    When I Run form on Web layout I noticed I have to right click in order to see the popup menu... Before in client server it would only require left mouse click and the popup menu would display.. is there anyway of setting it so it would display if I hit the left button vs the right button. Reason being users who are used to Non Web based will not know to hit the right mouse button vs. Hit the left mouse button..
    Anyway to fix this

    I would like to respectfully suggest that windows standards are such that a left-click will select an item, and a right-click will display a pop-up context menu if applicable. I believe the action you describe is how it should be. I mean, even on the page that I use to enter this very note, if I click a link or a button, it will perform the action, and if I right-click in this text box I get editing command shortcuts, right-click on a link I get options for how it is to open, etc.
    I don't believe a left click should open a context menu. If your users use other Windows standard programs, this should not be an issue, as this is how they work already.
    Gary

  • Can you set the color of a specific element in a JList?

    Is it possible to set the color of a single element in a JList without writing lines and lines of your own class? I know setForgroundColor exists, it just changes all element in a JList, so is there a simple way to tweak it? i am still a newbie, so re-writing swing, would be a bit of a problem for me. Any Suggestions? thanks.

    you write your own renderer, about 6-8 lines, setting the color determined by an
    if/else statement - note: you must set the color in both if and else
    search the forums for
    "implements ListCellRenderer"
    and you should find plenty of examples
    if you just want the selected element a different color, you can do this with
    UIManager.put("List.selectionBackground", new javax.swing.plaf.ColorUIResource(Color.YELLOW));
    but you must do this before you create the JList, and it will affect all JLists in your program.

  • FRM-92100 at toolbar canvases on calling popup-menus

    Hi all,
    I am migrating our 6i forms to 10g and now there is following problem.
    When I call the popup-menu, attached to a toolbar canvas, I´ll get the frm-92100 failure-message. On other canvas-types and items, there are no problems of calling popup-menus.
    What could cause this problem?
    thank you.

    Thanks for your reply,
    I´ve created a new popup menu and attached it, but it doesn´t work too.
    The error message says:
    Java Exception:
    oracle.ewt.popup.NoPopupOwnerException
    at oracle.ewt.IwAWT.IwMenu.LWPopupMenu._displayPopup(Unknown Source)
    at oracle.ewt.IwAWT.IwMenu.LWPopupMenu.popup(Unknown Source)
    at oracle.ewt.IwAWT.IwMenu.LWPopupMenu.popup(Unknown Source)
    at oracle.forms.handler.FormMenu.show(Unknown Source)
    at oracle.forms.handler.MenuInfo.showPopup(Unknown Source)
    at oracle.forms.handler.MenuInfo.onUpdate(Unknown Source)
    at oracle.forms.handler.MenuInfo.onUpdate(Unknown Source)
    at oracle.forms.engine.Runform.onUpdateHandler(Unknown Source)
    at oracle.forms.engine.Runform.processMessage(Unknown Source)
    at oracle.forms.engine.Runform.processSet(Unknown Source)
    at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
    at oracle.forms.engine.Runform.onMessage(Unknown Source)
    at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
    at oracle.ewt.IwAWT.LWComponent.redispatchEvent(Unknown Source)
    at oracle.ewt.IwAWT.LWComponent.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Thomas

  • Fireworks 8 CSS Popup Menus

    Hi,
    in previous versions of Fireworks I was able to create
    multiple popup menus and insert the menus into various table
    positions across a web page.
    In the latest version of Fireworks (8) I have tried to do the
    same using the CSS popup up menus but when previewing the page one
    or both of the menus fail to work properly. In some cases the popup
    menus appear onmouseover in the wrong place or other times the
    menus simply don't function at all.
    If I create a single CSS popup menu and insert into a page
    there is not a conflict and it is viewable in various browsers.
    Is there an adjustment that I can make to the code or the way
    that I export to Dreamweaver 8 so that multiple popup menus (in
    different tables) can function on the same page?
    Thanks,
    Boris

    Check the uberlink and McFly tutorials at PVII
    http://www.projectseven.com/)
    and the Navbar tutorial at Thierry's place (
    http://www.tjkdesign.com)
    Either of these are miles better than any DW/FW pop-up
    menu....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "borisbsp" <[email protected]> wrote in
    message
    news:e5pg36$nfb$[email protected]..
    >I would prefer a workaround to this problem (Since the
    money is spent on
    >the
    > software). However I will entertain other solutions as
    long as they can
    > provide me with the same design out come.
    >
    > The verticle popup menus need to be triggered by gif or
    jpeg images like
    > this:
    >
    > <a target=_blank class=ftalternatingbarlinklarge
    > href="
    http://www.eiptuning.com/eip/images/forum/navigation_01.jpg">Screen
    > Shot
    > Example</a>
    >
    > If you have some solutions that fit this criteria, and
    it doesn't mean
    > that I
    > have to reinvent the wheel, I would be interested.
    >
    > Thanks,
    > Boris
    >

Maybe you are looking for

  • How do I get a copy of iMovie 9?

    I reformatted my iMac hard drive with Lion. I restored from the downloaded version of Lion and therefore do not have iMovie on my system. I had upgraded to iMovie 9 but now it's not available in the App Store nor from iTunes. Does anyone know how I m

  • Standby database 11g

    Oracle 11.2. I am building standby database as a reporting database. Can physical standby database only be open read-only state? My understanding is yes, but I like to confirm it. If I want my standby database to be read/write, only logical standby d

  • PR Approval doesn't work properly in item category ranges

    We are facing anomalous behavior in purchase, we defined approval group based on item category ranges. When user submits PR for approval, it gets second approval as final approval. But actual this item get approve is next approval. When we incomplete

  • Software updates downloads timing out

    I have a 17 in. MPB bought in August 2007 and Im having a problem downloading certain firmware and software updates. they time out...Do I need a faster network? or is there a setting that I can expand my download times? Im thinking about going to at

  • How to guide: Avoid, that ERP In & Outbound Docs are planned in same FO

    Document can be found in SDN: https://cw.sdn.sap.com/cw/community/sce/external/blog/2012/01/25/how-to-avoid-that-erp-inbound-docs-po-inbound-delivery-out-docs-are-planned-in-the-same-freight-order-or-freight-booking