JidePopupMenu Location

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

JidePopupMenu Location

Postby robert » Sat Jun 21, 2008 9:03 am

After upgrading to 2.2.7, I am having some strange problems with the position of the JidePopupMenu. I have a JideButton that when pressed, triggers the display of the popup. I have found that the popup position varies depending on the position of the button! The button is in a toolbar on the top right side of the app window. When the button is added near the far right of the toolbar, the popup is displayed very far away from the button near the bottom of the app window. When the button is displayed more towards the center of the application, the popup is displayed correctly.

I replaced the 2.2.7 lib with the 2.2.3 lib that I used previously and the problem went away. I looked at the change log and I'm guessing this has something to do with "Fixed the position issue of JidePopupMenu when the Vista sidebar is on the left.". I have experienced this issue on Windows XP and Mac OS X. I don't have access to Vista so I don't know what happens on that OS.

Has anyone else experienced this issue?
robert
 
Posts: 41
Joined: Thu Apr 03, 2008 6:56 am

Postby JIDE Support » Sat Jun 21, 2008 1:57 pm

Do you have a simple test case for it?
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby robert » Sun Jun 22, 2008 3:42 pm

I will try and prepare a simple test case in the coming week. My application uses many other libs, so it will take some time to prepare a simple case that uses just jide and also demonstrates the problem.

When I pass my x,y coordinates to the popup, it seems that jide is changing them, dependent on the screen location of the button the triggered the popup. The problem seems to occur when the button is near the right edge of the screen. Anyway, I will post a test case as soon as I can.
robert
 
Posts: 41
Joined: Thu Apr 03, 2008 6:56 am

Postby JIDE Support » Sun Jun 22, 2008 5:26 pm

I simply mean a simple test case like this. I already tried myself but couldn't reproduce the issue. Maybe you can change it to reproduce it.

Code: Select all
import com.jidesoft.swing.JidePopupMenu;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class JidePopupMenuTest {
    public static void main(String[] args) {
        final JFrame d = new JFrame();
        d.setLayout(new GridBagLayout());
        JButton button = new JButton("Click to show popup menu");
        d.add(button);
        final JidePopupMenu popupMenu = new JidePopupMenu();
        for (int i = 1; i <= 10; i++) {
            popupMenu.add(new JMenuItem("Option " + i));
        }

        button.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                popupMenu.show(d, e.getX(), e.getY());
            }
        });
        d.setPreferredSize(new Dimension(200, 100));
        d.setVisible(true);
        d.pack();
    }
}
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby robert » Mon Jun 23, 2008 9:40 am

Maximize the frame in your test case and then click the button.
robert
 
Posts: 41
Joined: Thu Apr 03, 2008 6:56 am

Postby JIDE Support » Mon Jun 23, 2008 9:50 am

Sorry, my test case was wrong. Plesae change it to

Code: Select all
popupMenu.show((Component) e.getSource(), e.getX(), e.getY());


Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby robert » Mon Jun 23, 2008 11:39 am

OK, I've figured it out. The button in question is the only button in my toolbar that activates a popup, so it was linked to an ActionListener like all the other "normal" buttons in the toolbar. The ActionListener sent the x,y coordiantes of the button to the popup, not the x,y coordinates of where the mouse was clicked.

I have changed the listener to a MouseListener and it works now. I don't know if you consider this a bug or not. Using the popup with an ActionListener did work in 2.2.3. Also when using an ActionListener, the popup is displayed "under" the button which I would consider the correct location. When using the MouseListener, the popup is now displayed "over" the button which is not as nice.

Again, this does not affect all buttons, it depends on the screen location. I will create a test case that demonstrates the problem if you still need one, but won't be able to until tomorrow.
robert
 
Posts: 41
Joined: Thu Apr 03, 2008 6:56 am

Postby JIDE Support » Mon Jun 23, 2008 11:41 am

You can replace JidePopupMenu to JPopupMenu to see if the same thing exists. If JPopupMenu works fine but not JidePopupMenu, I will consider it as a bug. Otherwie it would be user error.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby robert » Mon Jun 23, 2008 12:04 pm

JPopupMenu works fine. The problem only occurs when using JidePopupMenu.
robert
 
Posts: 41
Joined: Thu Apr 03, 2008 6:56 am

Postby JIDE Support » Mon Jun 23, 2008 12:08 pm

If so, please send me a test case for it when you get the chance. In my test case, JidePopupMenu and JPopupMenu work the same way using either the right code or the wrong code.
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby robert » Mon Jun 23, 2008 1:12 pm

I got some time today to prepare the test. Click on each of the buttons and see how the position of the popup varies.

Code: Select all
import com.jidesoft.swing.JidePopupMenu;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JidePopupMenuTest extends JFrame {

    private JidePopupMenu popupMenu;

    public JidePopupMenuTest() {

        popupMenu = new JidePopupMenu();
        for (int i = 1; i <= 10; i++) {
            popupMenu.add(new JMenuItem("Option " + i));
        }

        ButtonHandler actionHandler = new ButtonHandler();
        JButton[] buttons = new JButton[10];
        JPanel buttonPanel = new JPanel();
        for (int i = 0; i < buttons.length; i++) {
            buttons[i] = new JButton("Click");
            buttons[i].addActionListener(actionHandler);
            buttonPanel.add(buttons[i]);
        }

        getContentPane().add(buttonPanel, BorderLayout.NORTH);
        pack();
        setVisible(true);
        setExtendedState(JFrame.MAXIMIZED_BOTH);

    }

    public static void main(String[] args) {

        new JidePopupMenuTest();
    }

    class ButtonHandler implements ActionListener {

        public final void actionPerformed(ActionEvent e) {

            JButton button = (JButton) e.getSource();
            popupMenu.show((Component) e.getSource(), button.getX(), button
                    .getY());
        }
    }
}

robert
 
Posts: 41
Joined: Thu Apr 03, 2008 6:56 am

Postby JIDE Support » Mon Jun 23, 2008 1:20 pm

I am sorry but the code is not right. If you use button as the owner of the menu, the x and y position should be 0, 0, not the button location as the location is relative to the button's parent.

Again, it is the same behavior as JPopupMenu. I changed the test to use JPopupMenu. You just change the last line to jidepopupmenu or popupmenu to see.

Code: Select all
import com.jidesoft.swing.JidePopupMenu;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class JidePopupMenuTest extends JFrame {

    private JidePopupMenu jidepopupMenu;
    private JPopupMenu popupMenu;

    public JidePopupMenuTest() {

        jidepopupMenu = new JidePopupMenu();
        popupMenu = new JPopupMenu();
        for (int i = 1; i <= 10; i++) {
            jidepopupMenu.add(new JMenuItem("Option " + i));
            popupMenu.add(new JMenuItem("Menu " + i));
        }

        ButtonHandler actionHandler = new ButtonHandler();
        JButton[] buttons = new JButton[10];
        JPanel buttonPanel = new JPanel();
        for (int i = 0; i < buttons.length; i++) {
            buttons[i] = new JButton("Click");
            buttons[i].addActionListener(actionHandler);
            buttonPanel.add(buttons[i]);
        }

        getContentPane().add(buttonPanel, BorderLayout.NORTH);
        pack();
        setVisible(true);
        setExtendedState(JFrame.MAXIMIZED_BOTH);

    }

    public static void main(String[] args) {

        new JidePopupMenuTest();
    }

    class ButtonHandler implements ActionListener {

        public final void actionPerformed(ActionEvent e) {

            JButton button = (JButton) e.getSource();
            (jide)popupMenu.show((Component) e.getSource(), button.getX(), button
                    .getY());
        }
    }
}
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby robert » Mon Jun 23, 2008 1:59 pm

Okay, thanks. I've corrected my code. I did a few other tests and found that JidePopupMenu 2.2.3 behaves exactly like JPopupMenu. However, JidePopupMenu 2.2.7 behaves slightly differently. If you run the test case with 2.2.7 and click the far right button you will see that the popup is displayed near the bottom of the frame. I don't know if this would be considered a bug or not. This is the issue I initially noticed in my application. With JidePopupMenu 2.2.3 and with JPopupMenu the popup is always displayed at the top of the frame. So the problem in my code never became evident until I used 2.2.7 and the popup suddenly moved to the bottom of the frame.

Anyway, I have fixed my code and everything is working fine.

Thanks
robert
 
Posts: 41
Joined: Thu Apr 03, 2008 6:56 am

Postby JIDE Support » Mon Jun 23, 2008 4:14 pm

That's probably a bug in 2.2.7 which we fixed in 2.2.8. So if you upgrade, everything should work fine.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 75 guests