Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialog bug when drag it with mouse #128

Closed
vincenzopalazzo opened this issue Apr 2, 2020 · 17 comments · Fixed by #118
Closed

Dialog bug when drag it with mouse #128

vincenzopalazzo opened this issue Apr 2, 2020 · 17 comments · Fixed by #118
Assignees
Labels
bug Something isn't working

Comments

@vincenzopalazzo
Copy link
Owner

No description provided.

@vincenzopalazzo vincenzopalazzo self-assigned this Apr 2, 2020
@vincenzopalazzo vincenzopalazzo added the bug Something isn't working label Apr 2, 2020
@vincenzopalazzo vincenzopalazzo linked a pull request Apr 2, 2020 that will close this issue
@vincenzopalazzo
Copy link
Owner Author

@jarek-insys, your PR has introduced a bug, I'm serving to reproduce it.

You will have more details in a few days.

Thanks.

@vincenzopalazzo
Copy link
Owner Author

Hi @jarek-insys,

I reproduced the bug and I'm try to understand why exist this bug in the resize windows?

ezgif com-video-to-gif

Thanks for your time

@jarek-insys
Copy link

Hi Vincent @vincenzopalazzo,

I have a little bit problem with reproducing that issue.
What java?
I did 1.8.0_171 no problem
1.8.0_241 no problem
10.0.1 no problem

Regards
Jarek

@vincenzopalazzo
Copy link
Owner Author

Hi @jarek-insys,

I use new JDK 13 but I think is the same with all, I think is important the dimension of the mainframe, can you run the demo inside the test dir??

In these cases I have a problem, I think you can help me because you write this code a few week the a go

@vincenzopalazzo
Copy link
Owner Author

@jarek-insys The bug is reproducible with JDK13, thanks for your help

@jarek-insys
Copy link

Hi @vincenzopalazzo,

integration.gui.mock.DemoGUITest
image
min size
image

System related?
I'm on windows 10

@vincenzopalazzo
Copy link
Owner Author

Hi @jarek-insys Linux, but tomorrow I can test on windows, but the bug is only to right corner, like the my forst gif.

Thanks.

@jarek-insys
Copy link

Hi @vincenzopalazzo,

:)

SLES15 java 13 no problem

Doesynmatter if I resize next to icon so somewhere else I cannot reproduce problem

@vincenzopalazzo
Copy link
Owner Author

Hi @jarek-insys,

I tested on the window and I don't have a problem but I have a problem with JDK 1.8 on Unix systems like Linux mint and OSX sierra.

do you have any idea?

@jarek-insys
Copy link

Hi @vincenzopalazzo,

:)
1.Mac - no problem
image
2. linuxmint-19.3-cinnamon-64bit
a 11 - no problem
image
b latest 8 no problem

I don't do magic

@vincenzopalazzo
Copy link
Owner Author

vincenzopalazzo commented Apr 14, 2020

Hi @jarek-insys,

Thanks for your help, really this is very strange.

It seems that depend on the APP, my test is

  • ArgoUML with JDK13: BUG

ezgif com-video-to-gif (1)

P.S: This test built now with 2 Display, so my work station is with two display(1 and 2)

I want to add my idea, you think that can depend on "How build the JFileChooser or the JDialog"?

In the DemoSwingRatio I declare the FileChooser with the following code, can you note any difference with your declarations?


        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle(resourceManager.getResourceString(Constant.FILECHOOSER_LOAD_IMAGE_TITLE));

        if (JFileChooser.APPROVE_OPTION == fileChooser.showOpenDialog(frame)) {
            File fileSelected = fileChooser.getSelectedFile();
            try {
                BufferedImage bufferedImage = ImageIO.read(fileSelected);
                if(bufferedImage == null){
                    frame.doShowMessage(MessageLevelError.ERROR, resourceManager.getResourceString(Constant.ERROR_LOAD_IMAGE));
                    return;
                }
                ImageIcon image = new ImageIcon(bufferedImage);
                JLabel label = panel.getBackgroundLabel();
                JButton button = panel.getAddBackground();
                panel.remove(button);
                label.setIcon(image);
                panel.add(label);
                mainPanel.refreshUI();
                //MaterialTost.makeText(frame, "Image added :)").display();
            } catch (IOException ex) {
                LOGGER.error(ex.getLocalizedMessage());
                frame.doShowMessage(MessageLevelError.ERROR, resourceManager.getResourceString(Constant.ERROR_LOAD_IMAGE));
                return;
            }
        }

Thanks for your work, before the release 1.1.1 I will work on this bug but if you want to try to fix it, I created a sandbox with my JDK version and a demo

Download Linux Sandbox

@jarek-insys
Copy link

Hi @vincenzopalazzo,

it's clear now problem is with bugged position over component solution is very simple
public void mousePressed(MouseEvent ev) {
Point p = SwingUtilities.convertPoint((Component)ev.getSource(),
ev.getX(), ev.getY(), null);
__x = ev.getX();
__y = ev.getY();
//fix
Point mouseCurent = MouseInfo.getPointerInfo().getLocation();
_x = mouseCurent.x;
_y = mouseCurent.y;
//_x = p.x;
//_y = p.y;
...
@SuppressWarnings("unchecked")
public void mouseDragged(MouseEvent e) {
if ( startingBounds == null ) {
// (STEVE) Yucky work around for bug ID 4106552
return;
}
Window w = (Window)e.getSource();
Point p = SwingUtilities.convertPoint((Component)e.getSource(),
e.getX(), e.getY(), null);

        Point mouseCurent = MouseInfo.getPointerInfo().getLocation();
        //fix
        int deltaX = _x - mouseCurent.x;
        int deltaY = _y - mouseCurent.y;
        //int deltaX = _x - p.x;
        //int deltaY = _y - p.y;

Regards
Jarek

@vincenzopalazzo
Copy link
Owner Author

Hi @jarek-insys,

Thanks for your help, tomorrow night I will test it inside for all use case.

I try to reproduce the problem with my monitor configurations and I will send you an update tomorrow at these hours.

Thanks and sorry for the return in the answer.

@vincenzopalazzo
Copy link
Owner Author

vincenzopalazzo commented Apr 21, 2020

HI @jarek-insys,

Sorry, the delay, I have the library under test for a project and I was a little busy with a memory profiling.

Now, I can talk about the problem, I update the code with your code and unfortunately don't resolve the problem, but before I want to talk about the problem with my display configuration.

I work with two monitors, main monitor and secondary monitor, in the first monitor your code work very well, but if you want to drag the dialog inside the second monitor the dragging work until the middle screen, after that the dragging work like this gif

Now, I start the debug and I start to see your code, but I'm losing here

                if (newX + i.left <= -viewX){
                    //What operation fo this?
                    newX = -viewX - i.left + 1;
                }else if (newY + i.top <= -viewY){
                    //What operation fo this?
                    newY = -viewY - i.top + 1;
                }else if (newX + viewX + i.right >= pWidth){
                    //What operation fo this?
                    newX = pWidth - viewX - i.right - 1;
                }else if (newY + viewY + i.bottom >= pHeight){
                    //What operation fo this?
                    newY = pHeight - viewY - i.bottom - 1;
                }

                dragFrame(w, newX, newY);

I have dyslexia and dyscalculia problem and for me is very difficult to read code like this without comment.

I think the problem is in this part of the code because the frame dragged fine on the main screen.

What do you think about this code? the problem should be inside this code? I think for you is simple to understand if the problem is here because you wrote this code.

I update the branch dev if you want to test the library with the actual code

EDIT with My SOLUTION

I found a solution, I added some print debug and I think I found the problem.

This line of code

Dimension dimensioDevices = Toolkit.getDefaultToolkit().getScreenSize(); return the wrong dimension in this cases.

When you work with a monitor, the dimension is the sum of the dimension, I change the code with the following

public MaterialRootPaneUI() {
        super();
        int devideWithd = 0;
        int deviceHeight = 0;
        GraphicsDevice graphicsDevices[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
        for(GraphicsDevice graphicsDevice : graphicsDevices){
            devideWithd += graphicsDevice.getDisplayMode().getWidth();
            deviceHeight += graphicsDevice.getDisplayMode().getHeight();
        }
         this.dimensioDevices = new Dimension(devideWithd, deviceHeight);
    }

and I move the propriety dimension of how class propriety, after that I run the test with more monitor and the test is green.

But this problem still exists inside the second monitor after the middle.

But now I want to ask your opinion about this solution.

Thanks for this idea exchange.

@jarek-insys
Copy link

Hi @vincenzopalazzo,

In general like I send before this code was just based on InternalFrameUI.
Where you have some parent bounds In this case You have desktop bounds.
That code is just to not place frame in invisible area where you cannot drag it back.
image
I'm not working usual with 2 screens so I dindn't notice that.
For your fix I'm not 100% sure about x position over multiple screens without testing but would say that you have only desktops on left or right so sum(with) is posible sum(height) make no sense since it's max(height) and more depend on x position if you are on 1 screen that it height, but when you move to next screen you have to compare with different height since both screens may have different resolution. When I'll have time i'll test that with 2 screens.

Regards
Jarek

@vincenzopalazzo
Copy link
Owner Author

Hi @jarek-insys,

Thanks for this additional information, I think inside the code of the library there is a logic error.

I don't know because is necessary to duplicate the code inside RootPane, the library use the BasicInternalFrameUI.

I need to look inside the code to found the problem, if the code exist we can use this code without the JRootPane.

@vincenzopalazzo
Copy link
Owner Author

Fixed inside material-ui-swing-1.1.1-rc1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants