JPopupMenu with multiline JMenuItem ?

Hi there.
Is it possible to do something like the subject says, a JPopupMenu with multiline JMenuItem's, without using html? I would like to create a JMenuItem with a MultiLineLabel as the argument instead of a String. I'm trying to do this because if i add the MultiLineLabel directly to the JPopupMenu, it displays as i want, but i loose the behaviour inherent to a JMenuItem, the highlighted index, etc.. Any help would be appreciated.

Here's a workaround:
JPopupMenu popupMenu = new JPopupMenu();
// Workaround to stop first menu item being selected
JMenuItem dummyItem = popupMenu.add(new JMenuItem());
dummyItem.setPreferredSize(new Dimension(0, 0));
popupMenu.add("Item 1");
popupMenu.add("Item 2");
popupMenu.add("Item 3");
It works for me!

Similar Messages

  • JPopupMenu with a JScrollPane

    I have couple of questions
    1. I want to add a JScrollPane to JPopupMenu, doing this would not make the JPopupMenu visible. Is this doable?
    2. this is not related to question 1
    I have a JPOpupMenu with JMenuItems. When I select one of items and the item selected , I append the String to a JTextArea.
    The focus goes back to th beginning of the textArea, I want the focus to be at the end of string that is appended to the textArea.
    thanx

    I might sounding dense here, but I tried all the suggestions, it does not help. The textArea does not even get displayed.
    Also I noticed another thing, the JtextArea is registered with a mouseListener. But when I right click on JTextField , I get teh popup. Which is strange.
    I have attached the code with the above suggestions.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    public class TextChooserDemo extends JFrame{
         private JTextField field;
         private JLabel label1;
         private JLabel label2;
         private JPanel aPanel ;
         private JPanel bPanel;
         private JTextArea textArea;
        private TextChooser chooser;
        public TextChooserDemo() {
            initComponents();
            chooser=new TextChooser(this,textArea);
        private void initComponents() {
              field = new JTextField(20);
              label1 = new JLabel("Label1");
              textArea = new JTextArea();
              aPanel = new JPanel();
              aPanel = new JPanel();
              aPanel.setLayout(new BorderLayout());
              aPanel.add(label1, BorderLayout.WEST);
              aPanel.add(field, BorderLayout.CENTER);
              label2 = new JLabel("Label2");
              bPanel = new JPanel();
              bPanel.setLayout(new BorderLayout());
              bPanel.add(label2, BorderLayout.WEST);
              aPanel.add(textArea, BorderLayout.CENTER);
            setTitle("Text-Chooser Demo");
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            getContentPane().add(aPanel,BorderLayout.NORTH );
            getContentPane().add(bPanel,BorderLayout.CENTER);
            //getContentPane().add(aPanel );
            //getContentPane().add(bPanel);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-500)/2, (screenSize.height-350)/2, 500, 350);
        public static void main(String args[]) {
            new TextChooserDemo().setVisible(true);
    class TextChooser extends JWindow {
        public TextChooser(JFrame parent, JTextArea textArea){
            super(parent);
            this.parent=parent;
            this.textArea=textArea;
            initChooser();
        private void initChooser(){
            textArea.addMouseListener(new MouseAdapter() {
                public void mouseReleased(MouseEvent evt) {
                    textAreaMouseReleased(evt);
            popupScrollPane = new JScrollPane();
            popupList = new JList();
            popupList.setModel(new AbstractListModel() {
                String[] strings = { "java ", "is ", "cool ", "and ", "nice ", "to ", "have ", "with ", "no ", "error ", ".\n" };
                public int getSize() { return strings.length; }
                public Object getElementAt(int i) { return strings; }
    popupList.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent evt) {
    popupListAction(evt);
    popupScrollPane.setViewportView(popupList);
    getContentPane().add(popupScrollPane);
    private void popupListAction(ListSelectionEvent evt) {
    if (evt.getValueIsAdjusting() == false) {
    textArea.append((String)popupList.getSelectedValue());
    try{
    textArea.setCaretPosition(textArea.getLineEndOffset(textArea.getLineCount()-1));
    }catch(BadLocationException ex){ex.printStackTrace();}
    setVisible(false);
    textArea.requestFocus();
    private void textAreaMouseReleased(MouseEvent evt) {
    Point pnt = evt.getPoint();
    int x = (int)pnt.getX()+(int)parent.getX();
    int y = (int)pnt.getY()+(int)parent.getY()+20;
    if( !contains(x,y) ){
    setVisible(false);
    if(evt.isPopupTrigger()){
    setBounds(x,y,200,100);
    setVisible(true);
    private JFrame parent;
    private JTextArea textArea;
    private JScrollPane popupScrollPane;
    private JList popupList;
    thnx again!!!

  • JPopupMenu with JCheckBoxMenuItmes

    Hi,
    I have a JPopupMenu with JCheckBoxMenuItems and JMenuItems.
    The default behaviour of the JPopupMenu is, that it closes on selection of a MenuItem. This behaviour is not really nice for the CheckBoxMenuItems !
    Does anyone know a workaround?
    Thanks,
    Elke

    I don't have a workaround, sorry. But I think thats not needed too. The behavior you don't seem to like, is consistent with every application I ever used.
    When I click on a menuitem, the only actions I expect is that either the menu closes and a command is executed, or another pop-up menu appears where I make my choice.
    If you had a menu that doesn't close when you select or deselect a CheckBoxMenuItem, how do you close that menu? I think a MenuItem "Close this menu" would not be appreciated by any user. I use CheckBoxes on menus sparingly, and only for actions that generate an immediate visual response. (For instance Grayscale Image vs. Colored Image).
    If you want the user to have more control about options its better you create a small dialog with your choices and an accept/cancel set of buttons.
    Sorry I couldn't help with your initial question.

  • JPopupMenu with JInternalFrame, popup menu doesn't work

    hi, i have this problem, as shown in the sample code at the end of this post.. basically, i have a table, and i added a JPopupMenu onto the table.. the popup menu works well when running the table class, though, when i call the table class in a JInternalFrame environment, the popup menu won't work.. anyone know why?
    ///Basic sample table code, when run this alone, the popup menu will work
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TableBasic extends JPanel
         private JTable table;
         public TableBasic()
              String[] columnNames = { "Date", "String", "Integer", "Boolean" };
              Object[][] data =
                   {  { new Date(), "A", new Integer(1), Boolean.TRUE },
                        { new Date(), "B", new Integer(2), Boolean.FALSE },
                        { new Date(), "C", new Integer(9), Boolean.TRUE },
                        { new Date(), "D", new Integer(4), Boolean.FALSE}
              table = new JTable(data, columnNames)
                   //Returning the Class of each column will allow different
                   //renderers to be used based on Class
                   public Class getColumnClass(int column)
                        return getValueAt(0, column).getClass();
              table.setPreferredScrollableViewportSize(table.getPreferredSize());
              JScrollPane scrollPane = new JScrollPane(table);
              add(scrollPane);
         public void createPopupMenu()
              JMenuItem menuItem;
              //Create the popup menu.
              JPopupMenu popup = new JPopupMenu();
              menuItem = new JMenuItem("A popup menu item");
              //menuItem.addActionListener(this);
              popup.add(menuItem);
              menuItem = new JMenuItem("Another popup menu item");
              //menuItem.addActionListener(this);
              popup.add(menuItem);
              //Add listener to the text area so the popup menu can come up.
              MouseListener popupListener = new PopupListener(popup);
              table.addMouseListener(popupListener);
         public static void main(String[] args)
              JFrame frame = new JFrame();
              TableBasic table = new TableBasic();
              table.createPopupMenu();
              frame.setContentPane(table);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
              //frame.setLocationRelativeTo(null);
              frame.setVisible(true);
         class PopupListener extends MouseAdapter
              JPopupMenu popup;
              PopupListener(JPopupMenu popupMenu)
                   popup = popupMenu;
              public void mousePressed(MouseEvent e)
                   maybeShowPopup(e);
              public void mouseReleased(MouseEvent e)
                   maybeShowPopup(e);
              private void maybeShowPopup(MouseEvent e)
                   if (e.isPopupTrigger())
                        popup.show(e.getComponent(), e.getX(), e.getY());
    ///when integrate the previous table into here, popup menu won't work
    import java.awt.*;
    import javax.swing.*;
    public class InternalFrameBasic
         extends JFrame
         //implements ActionListener
         private JDesktopPane desktop;
         private JInternalFrame menuWindow;
         public static final int desktopWidth = 800;
         public static final int desktopHeight = 700;
         public InternalFrameBasic(String title)
              super(title);
              //Set up the GUI.
              desktop = new JDesktopPane();
              desktop.putClientProperty("JDesktopPane.dragMode", "outline");
              //Because we use pack, it's not enough to call setSize.
              //We must set the desktop's preferred size.
              desktop.setPreferredSize(new Dimension(desktopWidth, desktopHeight));
              setContentPane(desktop);
              createMenuWindow();
              desktop.add(menuWindow); //DON'T FORGET THIS!!!
              Dimension displaySize = menuWindow.getSize();
              menuWindow.setSize(desktopWidth, displaySize.height);
         private void createMenuWindow()
              menuWindow =
                             new JInternalFrame("Event Watcher", true, //resizable
                                                                                                   true, //closable
                                                                                                   false, //not maximizable
                                                                                                   true); //iconifiable
              menuWindow.setContentPane(new TableBasic());
              menuWindow.pack();
              menuWindow.setVisible(true);
          * Create the GUI and show it.  For thread safety,
          * this method should be invoked from the
          * event-dispatching thread.
         private static void createAndShowGUI()
              //Make sure we have nice window decorations.
              //JFrame.setDefaultLookAndFeelDecorated(true);
              //Create and set up the window.
              JFrame frame = new InternalFrameBasic("Example Internal Frame");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args)
              //Schedule a job for the event-dispatching thread:
              //creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        createAndShowGUI();
    }

    table.createPopupMenu();The above line should not be in the main method. It should be in the constructor class of TableBasic.
    You never execute that method in your InternalFrameBasic class to the mouse listener never gets added to the table.

  • Problem with multiline text item return on query

    Hi there, I am a beginner in ORACLE, here when i write a query i engaged a weird problem,
    LOOP
    FETCH CSR_ODR2 INTO :ORDER_RECORD.OREDER_RECORD_NO,:ORDER_RECORD.BILL_NO,:ORDER_RECORD.ACTUALO_WEIGHT,:ORDER_RECORD.OPERATION,:ORDER_RECORD.PLACE,:ORDER_RECORD.TRANSACTION_DATE,:ORDER_RECORD.ORDER_NO;
    EXIT WHEN CSR_ODR2%NOTFOUND;
    END LOOP;
    this is the cursor version, I also tried SELECT statement, but have trouble about return more than 1 row.
    :Order_Record is a detailed-form with multiline text items,while execute this cursor, it always rewrite the 1st line and wont go to 2nd line, I wanna get some help about how to display different records in different line in a text item.
    btw, i tried next_record,next_item,next_field, but none of them works, the query is based on the record i filled on the master form, and show related record in detailed-form
    Kyle
    Edited by: user12234866 on 13-Jun-2010 00:32

    DECLARE
    CURSOR CSR_ORDER IS
    SELECT T.ORDER_DATE,T.WEIGHT,T.CUSTOMER,T.DRIVER_NO,T.INVOICE_NO,T.LICENSE_NR_TRUCK,T.PRODUCT,T.PRICE_PER_TON,T.TRAILER_NO
    FROM TRANSPORT_ORDER T
    WHERE T.ORDER_NO=:TRANSPORT_ORDER.ORDER_NO;
    BEGIN
    OPEN CSR_ORDER;
    LOOP
    FETCH CSR_ORDER INTO :TRANSPORT_ORDER.ORDER_DATE,:TRANSPORT_ORDER.WEIGHT,:TRANSPORT_ORDER.CUSTOMER,:TRANSPORT_ORDER.DRIVER_NO,:TRANSPORT_ORDER.INVOICE_NO,:TRANSPORT_ORDER.LICENSE_NR_TRUCK,:TRANSPORT_ORDER.PRODUCT,:TRANSPORT_ORDER.PRICE_PER_TON,:TRANSPORT_ORDER.TRAILER_NO;
    EXIT WHEN CSR_ORDER%NOTFOUND;
    END LOOP;
    END;
    DECLARE
    CURSOR CSR_ODR2 IS
    SELECT O.OREDER_RECORD_NO,O.BILL_NO,O.ACTUALO_WEIGHT,O.OPERATION,O.PLACE,O.TRANSACTION_DATE,O.ORDER_NO
    FROM ORDER_RECORD O
    WHERE O.ORDER_NO=:TRANSPORT_ORDER.ORDER_NO
    ORDER BY OREDER_RECORD_NO asc;
    BEGIN
    OPEN CSR_ODR2;
    GO_BLOCK(':ORDER_RECORD');
    LOOP
    FETCH CSR_ODR2 INTO :ORDER_RECORD.OREDER_RECORD_NO,:ORDER_RECORD.BILL_NO,:ORDER_RECORD.ACTUALO_WEIGHT,:ORDER_RECORD.OPERATION,:ORDER_RECORD.PLACE,:ORDER_RECORD.TRANSACTION_DATE,:ORDER_RECORD.ORDER_NO;
    EXIT WHEN CSR_ODR2%NOTFOUND;
    END LOOP;
    END;
    thats the stuff i wrote here to execute

  • How to get the JMenuBar associated with a JMenuItem?

    How do I get the JMenuBar (or JFrame) associated with
    a JMenuItem?
    The JMenuItem is in a subMenu of a JMenu on the JMenuBar.

    Hi,
    JMenuBar is extending from the container class,
    When a menuItem is added to it,You can get the instance of JMenuBar by type casting the getParent method on JMenuItem
    ie..
    JMenuItem mi1 = new JMenuItem();
    JMenuBar jm = new JMenuBar();
    jm.add(mi1);
    JMenuBar jm2 = (JMenuBar) mi1.getParent();
    Hope this helps
    cheers
    Ravi

  • Probleme on JPopupMenu with JDialog

    I use JPopupMenu with JDialog. To display the popup, I use a mousePressed in a panel of the dialog:
    public void mousePressed(MouseEvent e) {
    if( e.getClickCount()==1 && e.getModifiers()==MouseEvent.BUTTON3_MASK && ga!=null ) {
         mpopup.show(e.getComponent(),e.getX(), e.getY());
    It works fine, but when a part of the popup is out of the dialog, the popup doesn't display.
    Is it normal?
    Has someone already had this problem?
    I work with jdk1.3.1_01
    Thanks for your help
    Templ

    When you create your popup menu do this :
    mpopup.setLightWeightPopupEnabled(false);
    I hope this helps,
    Denis

  • JMenu with no JMenuItem

    Hi!
    I have a JMenuBar with one JMenu (File) and its JMenuItems.
    I want to add another JMenu (settings) but with no JMenuItems, so when the user clicks on settings a new window is shown.
    Is this possible?

    You need to add a MenuListener to the higher level menu. See attached sample working code.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class MenuTest
      public static void main(String args[])
        new MenuTestFrame();
    class MenuTestFrame extends JFrame implements ActionListener
      JMenuBar mb = new JMenuBar();
      JMenu file = new JMenu("File");
      JMenu edit = new JMenu("Edit");
      JMenu view = new JMenu("View");
      JMenu help = new JMenu("Help");
      JMenuItem fileOpen = new JMenuItem("Open...");
      JSeparator separator = new JSeparator();
      JMenuItem fileSaveAs = new JMenuItem("Save As...");
      JMenuItem editCut = new JMenuItem("Cut");
      JMenuItem editCopy = new JMenuItem("Copy");
      JMenuItem editPaste = new JMenuItem("Paste");
      JMenuItem helpAbout = new JMenuItem("About...");
      MenuTestFrame()
        super();
        /* Components should be added to the container's content pane */
        Container cp = getContentPane();
        /* Add menu items to menus */
        file.add(fileOpen);
        file.add(separator);
        file.add(fileSaveAs);
        edit.add(editCut);
        edit.add(editCopy);
        edit.add(editPaste);
        help.add(helpAbout);
        /* Add menus to menubar */
        mb.add(file);
        mb.add(edit);
        mb.add(view);
        mb.add(help);
        /* Set menubar */
        setJMenuBar(mb);
        /* Add the action listeners */
        fileOpen.addActionListener(this);
        fileSaveAs.addActionListener(this);
        editCut.addActionListener(this);
        editCopy.addActionListener(this);
        editPaste.addActionListener(this);
        helpAbout.addActionListener(this);
        /* Add menu listener */
        view.addMenuListener(new MenuListener() {
          public void menuCanceled(MenuEvent evt) {}
          public void menuDeselected(MenuEvent evt) {}
          public void menuSelected(MenuEvent evt)
            SwingUtilities.invokeLater(new Runnable() {
              public void run() {
                JOptionPane.showMessageDialog(MenuTestFrame.this,"Menu test dialog!","Message",JOptionPane.INFORMATION_MESSAGE);
        /* Add the window listener */
        addWindowListener(new WindowAdapter()
          public void windowClosing(WindowEvent evt)
            dispose();
            System.exit(0);
        /* Size the frame */
        setSize(200,200);
        /* Center the frame */
        Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
        Rectangle frameDim = getBounds();
        setLocation((screenDim.width - frameDim.width) / 2,(screenDim.height - frameDim.height) / 2);
        /* Show the frame */
        setVisible(true);
      public void actionPerformed(ActionEvent evt)
        Object obj = evt.getSource();
        if (obj == fileOpen);
        else if (obj == fileSaveAs);
        else if (obj == editCut);
        else if (obj == editCopy);
        else if (obj == editPaste);
        else if (obj == helpAbout);
    }

  • JPopupMenu with a submenu (doesn't work)

    I have a JPopupMenu that displays some info for me and I would like to add a submenu but it doesn't seem to work. I can successfully add the submenu but it doesn't "expand" when I mouse over the submen.
    JPopupMenu pm = new JPopupMenu();
    JMenu submenu = new JMenu("submenu");
    JMenuItem jmi = new JMenuItem(...);
    submenu.add(jmi);
    pm.add(submenu);The popup menu looks as it should and the only thing that is missing is the action that should expand the submenu when I mouse over (and clicking doesn't work either).
    Any ideas?

    I don't think it is my code because I have tried it with other JPopupMenu stuff and it never works. Here is a simple working example of it. If you can modify this code to work I will be a bielver...
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JPopupMenu;
    public class PopUpMenuTest extends JPanel implements MouseListener, MouseMotionListener {
       private JPopupMenu jpm;
       private JFrame frame;
       public PopUpMenuTest() {
          super();
          addMouseListener(this);
          addMouseMotionListener(this);
          JFrame.setDefaultLookAndFeelDecorated(true);
          frame = new JFrame("Testing PopUpMenuTest");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setContentPane(this);
          frame.setSize(600, 400);
          frame.setVisible(true);
       public static void main(String[] args) {
          new PopUpMenuTest();
       public void mouseClicked(MouseEvent me) {
          System.out.println("Mouse clicked...");
          jpm = new JPopupMenu();
          jpm.setLightWeightPopupEnabled(false);
          jpm.add(new JMenuItem("Testing 1"));
          jpm.add(new JMenuItem("Testing 2"));
          jpm.addSeparator();
          JMenu submenu = new JMenu("A submenu");
          JMenuItem menuItem1 = new JMenuItem("An item in the submenu");
          submenu.add(menuItem1);
          JMenuItem menuItem2 = new JMenuItem("Another item");
          submenu.add(menuItem2);
          jpm.add(submenu);
          jpm.setVisible(true);
          jpm.setLocation(frame.getX()+me.getX(), frame.getY()+me.getY());
          jpm.setVisible(true);
       public void mouseMoved(MouseEvent arg0) {
          if (jpm != null) {
             jpm.setVisible(false);
             jpm = null;
       public void mouseEntered(MouseEvent arg0) {}
       public void mouseExited(MouseEvent arg0) {}
       public void mousePressed(MouseEvent arg0) {}
       public void mouseReleased(MouseEvent arg0) {}
       public void mouseDragged(MouseEvent arg0) {}
    }

  • JPopupMenu with submenu

    Hello,
    I have a grid of buttons. If the user clicks a button with the right mouse button,
    a JPopupMenu shows up. The popup menu includes also 2 submenus (JMenu).
    When the user selects a menuitem, I need to know which was the selected button,
    because it identifies the object on which the operation has to be performed.
    If the menuitem is not in a submenu, I can get the button using
                   menuItem = (JMenuItem) arg0.getSource();
                   JPopupMenu popup = (JPopupMenu) menuItem.getParent();
                   b = (JButton) popup.getInvoker();But if the selected menuitem is in the submenu, popup.getInvoker returns the JMenu (submenu)
    and not the button.
    How do I get which button was pressed?
    thanks Marina

    Sorry it is not clear to me how.
    This is the code that shows the popup
    mb.addMouseListener( new java.awt.event.MouseListener() {
              public void mouseEntered(MouseEvent e) {
              public void mouseExited(MouseEvent e) {
              public void mouseReleased(MouseEvent e) {
              public void mouseClicked(MouseEvent e) {
                   if (e.getButton() == MouseEvent.BUTTON3)
                        JButton button = (JButton)e.getSource();
                        if (button.isEnabled())
                             mcPopup.show(button,0,button.getHeight());
              public void mousePressed(MouseEvent e) {
    The different clicks are then handled by the ActionListener:     if(actionString.equals("ccbinfo")) //default action for left click on the button
                   b = (JButton) arg0.getSource();
              else if (actionString.contains("power")) //action for submenu items
                   menuItem = (JMenuItem) arg0.getSource();
                   JPopupMenu popup = (JPopupMenu) menuItem.getParent();
                   b = (JButton) ?
              else // action for popup items (not in submenu)
                   menuItem = (JMenuItem) arg0.getSource();
                   JPopupMenu popup = (JPopupMenu) menuItem.getParent();
                   b = (JButton) popup.getInvoker();
    In the ActionListener the button information from the MouseClicked event is not available,
    how do I pass the button info to the menu?
    The menu is constructed only once, and the attached to the button only when right clicked.     private void buildPopupMenu()
              mcPopup = new JPopupMenu();
              pwrOnPopup = new JMenu("Power on"); //submenu
              pwrOffPopup = new JMenu("Power off"); //submenu
    ... //build and add items
         mcPopup.add(pwrOnPopup);
         mcPopup.add(pwrOffPopup);
    thanks Marina                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Trouble with multiline text box reading from xml file

    Hi,
    I have a text area, set to multiline.  For some reason, when my text imported from xml shows up in the box, it starts several lines down into the box.  So for example, my Text box is positioned with the top at the midpoint of my stage, but the text starts about 3/4 down the page, about half way down the text box.  Can someone please tell me why this is happening and what I can do to fix it?
    I noticed that when I put my cursor in the box and move it up and down, the rest of the text 'scrolls' into the frame, but otherwise it's cut off.  please help!
    Thanks,
    Stan

    Could you show your XML?

  • How to show a JPopupMenu on a JMenuItem?

    I am trying to add a RMB context menu to an existing JMenuItem. For example Firefox has bookmark popup menus that can be "edited" by right clicking on the popup menu to say delete an entry.
    The code below is a sample app that demonstraits the problem. Open up the main menu and attempt to right click on various things.
    It seems like it might will work for "sub" JMenus but not JMenuItems (meaining no exception in thrown). In either case the menu to which the popup should be attached disappears when the RMB is clicked (at least on windows). This is likely the cause of the exception that is thrown below when the RMB is clicked on a JMenuItem. Furthermore if the popup is shown it is not properly hidden.
    How would one properly accomplish this or is it just plain impossible?
    java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
         at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:1507)
         at java.awt.Component.getLocationOnScreen(Component.java:1481)
         at javax.swing.JPopupMenu.show(JPopupMenu.java:921)
         at sample.App$MouseHandler.checkPopup(App.java:76)
         at sample.App$MouseHandler.mouseReleased(App.java:69)
         at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:232)
         at java.awt.Component.processMouseEvent(Component.java:5100)
         at java.awt.Component.processEvent(Component.java:4897)
         at java.awt.Container.processEvent(Container.java:1569)
         at java.awt.Component.dispatchEventImpl(Component.java:3615)
         at java.awt.Container.dispatchEventImpl(Container.java:1627)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
         at java.awt.Container.dispatchEventImpl(Container.java:1613)
         at java.awt.Window.dispatchEventImpl(Window.java:1606)
         at java.awt.Component.dispatchEvent(Component.java:3477)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    package sample;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class App {
    private JFrame frame;
    private JPopupMenu popup;
    public static void main( String[] args ) {
    try {
    new App();
    catch( Exception e ) {
    e.printStackTrace();
    public App() {
    popup = createPopupMenu();
    frame = new JFrame( "Sample" );
    frame.addWindowListener( new WindowHandler() );
    frame.setSize( 200, 200 );
    frame.setJMenuBar( createMenuBar() );
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(
    screenSize.width/2-frame.getWidth()/2,
    screenSize.height/2-frame.getHeight()/2 );
    frame.setVisible( true );
    private JMenuBar createMenuBar () {
    JMenuBar bar;
    JMenu menu, submenu;
    JMenuItem item;
    bar = new JMenuBar();
    menu = new JMenu ( "Menu" );
    bar.add ( menu );
    item = new JMenuItem( "Item" );
    item.addMouseListener( new MouseHandler() );
    menu.add( item );
    submenu = new JMenu ( "SubMenu" );
    submenu.addMouseListener( new MouseHandler() );
    menu.add ( submenu );
    item = new JMenuItem( "SubItem" );
    item.addMouseListener( new MouseHandler() );
    submenu.add( item );
    return bar;
    private JPopupMenu createPopupMenu() {
    JPopupMenu popup = new JPopupMenu();
    popup.add( "Popup" );
    return popup;
    private class MouseHandler extends MouseAdapter {
    private void checkPopup( MouseEvent e ) {
    if( e.isPopupTrigger() ) {
    popup.show( e.getComponent(), e.getX(), e.getY() );
    public void mousePressed( MouseEvent e ) {
    checkPopup( e );
    public void mouseReleased( MouseEvent e ) {
    checkPopup( e );
    public void mouseClicked( MouseEvent e ) {
    checkPopup( e );
    private class WindowHandler extends WindowAdapter {
    public void windowClosing( WindowEvent e ) {
    System.exit( 0 );

    I've looked there. If there is help there for popping up a context menu on top of another menu I can't find it. Could you please be a bit more specific? Did you try the sample code?

  • Problem with multiline

    Dear all,
    My requirement is like thiis.
    I have n senders(10) which i need to merge in to 1 and send to the receiver.
    Logic implemented:
    1)Loop:
    Counter!=5.
    2)Receiver
    LineElement
    3)Container1
    Append single line element to multi line element
    4)container2
    Assign counter+1.
    end loop
    5)Transfermation
    interface mapping
    Single line element
    target interface
    Note:
    If I take the line item as Multiline I am geeting an error that the element must not return multi line
    6)send
    targetinterface
    when I execute the same I am getting 2 different messages ie 2 different files are generated with out merging.
    Kindly help.
    Thanks,
    Srinivas

    Hi
    use the following process in the BPM
        start>loop>receive>container1>container2>transform>send-->stop
    container1-->to collect the multiple idocs.
    container2-->to increment the value of the variable to check the loop condition.
    >If I take the line item as Multiline I am geeting an error that the element must not return multi line
    if you are getting the error as, that the element must not return multi line
    for that check whether the occurence for the target node is 0..unbounded.
    Thanks
    Rinku

  • Problems with multiline.jar

    Hello there,
    I have implemented multiline help for text items using multiline.jar provided by oracle.
    I have several pages i.e fmx's, user can traverse to using oracle menus in my application.
    I have multiline.jar for say "Test.fmb" only. Test.fmb has several items, blocks and tabbed pages within itself.
    Sometimes, when i am on textitem1, the help will show up. but even if i move the cursor or go to other fmx's the help doesn't go away. Does anybody have this problem?
    If i close down the application & start again it's fine.
    Please help me.
    Thanks

    Can you post an example project that demonstrates the problem? There were changes to the ant tasks and netbeans support around B45 that could cause problems depending on which version of the SDK and NetBeans you have. Similarly, if you wrote ant scripts prior to B44 and then use them with a later build you could have problems. And of course, if you're producing the Jar file and deployment artifacts without using the provided ant tasks (for example, using the normal ant jar task) you'll have problems.
    I've verified that this works as expected in the FX 2.0 GA release using ant from the command line, and with the NetBeans 7.1 beta release using the FX 2.0 GA release.

  • Populate combobox with multiline field

    Is there a way to get an array of a multiline text field and put this array in a combobox?
    I think i have to use the split() function, but i dont know how to do this.
    I'm trying to find an easy way to populate a combobox.

    This topic shows how you can split the value of a multiline text field's value at carriage returns: http://forums.adobe.com/thread/789976
    You can then use the setItems field method to populate the combo box with the items: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.752.html

Maybe you are looking for

  • Volume and brightness keys not working with new keyboard on imac

    I just purchased a new wired keyboard for imac and brightness and volume control keys not working . i have tried adjusting keyboard settings. I have software version 10.5.8. Do I need to upgrade software. Thank you for any help.

  • Regarding Workflow condition

    Hello, i need help regarding workflow condition.. When the Owner of the record gets changed to a specific user i want to create a set of tasks automatically created,.. is it possible using workflows, if possible what is the trigger event i have to us

  • Aol keeps asking for passwords,using os 10.9.2

    I have deleted account and reconfigured, deleted keychain and it still asking for password. HELP! Driving me nuts.

  • How do I encrypt pdf form on Submit by email

    Hi, Is there anyway to encrypt the pdf form after the user clicks on the "Submit by Email" button? I have Acrobat 9.

  • Ultradev 4 php

    Hi there, I am using Dreamweaver Ultradev 4.  Very old I know. I would like to set myself up for a database connection using php, mysql.  I can't seem to find a compatible server model extension to set up my site.  I have tried the one from Adobe but