Dragging bug

I’m using the last version from Github, and I’ve created a demo using the excellent “Commons” manual.

However, when dragging a dockable and dropping it on top of itself or another dockable (so it will get stacked), the “flying toolbar” that you drag and drop gets stuck in place, as well as the blue transparency on top of my panel, even when I move to another application. Sometimes waiting a bit before letting the mouse button go is enough for it not to happen, but obviously I cannot expect my users to do that ).

Is this a bug, or I might be doing something wrong? Sorry about the naming of things, I haven’t found names for everything in the manual :).

Let me know if you need a screenshot or any other info. Thanks!

Are you using Linux? In my experience Swing stopped working properly on Linux since Java 7 :frowning:

Are there any exceptions on the console?

I’m on Mac, forgot to mention, sorry. Well, I’m using IntelliJ in all my platforms (and as far I understand, they heavily use Swing) and it works properly. And no, no exceptions :(.

Hm, I have no clue…

Could you please add a global AWTEventListener to your application, and check that there is a “MouseReleased”-Event when you try to drop the Dockable? I could imagine that a Mac works slightly different than a Linux/Windows machine, maybe some workaround is required to find out the moment when drag&drop operation ended.

			@Override
			public void eventDispatched(AWTEvent event) {
				System.out.println(event);
			}
		}, MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK);

Sorry, I completely forgot that you replied already. The output is here: http://pastie.org/private/pkelavjtikrxgtmzyjjwtq.

As you can see, there is a MOUSE_RELEASED event, and if I’m reading that correctly, it’s associated with the right component (I just dragged the title bar of my panel, and dropped it on the body of the same panel). Do you see something wrong there?

Thanks for the log.

In the log mouse-pressed and mouse-released do not point to the same Component. There is a MouseListener attached to the AbstractMultiDockTitle, waiting for the mouse-released event. But in the log the event is sent to the TabbedTilesetsPanel, and the title is not informed about that event. Funny enough, the mouse-dragged events are sent to the right Component. The events perfectly match your observations that the title is dragged around, but nothing happens when you release the mouse.

java.awt.event.MouseEvent[MOUSE_PRESSED,(62,19),absolute(790,64),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] on bibliothek.gui.dock.title.AbstractMultiDockTitle$1[,17,0,213x22,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777217,maximumSize=,minimumSize=,preferredSize=]

java.awt.event.MouseEvent[MOUSE_RELEASED,(114,116),absolute(830,230),button=1,modifiers=Button1,clickCount=0] on tiled.mapeditor.widget.TabbedTilesetsPane[,0,32,297x312,layout=com.apple.laf.AquaTabbedPaneUI$AquaTruncatingTabbedPaneLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777568,maximumSize=,minimumSize=,preferredSize=,haveRegistered=false,tabPlacement=TOP]

I think I can add a global mouse-listener in the framework and just stop the currently active drag-and-drop operation once I see a mouse-released event. I’ll try that on the next weekend, and then we can check out if that change helps you (and if not, then it is not a bad change anyways).

(Also: I currently have no better idea on how to resolve the issue. Better solutions are welcome :wink: )

I’ve uploaded a new version 1.1.1p12e (it’s also pushed onto Github). This version includes a global-mouse listener that will stop any drag-and-drop operation if it sees a mouse-released event. Please try it, and let me know if that solves your problem.

Sorry again for the late reply, but for some reason, I’m not getting mails from this forum at all.

Anyway, thanks a lot for your work! I’ll test it as soon as I can and will let you know if it works! (don’t have access to the Mac machine right now)

I can reproduce the above or similar bug in 1.1.1 p7e with Java 8 and the below code by dragging the blue dockable tab downwards.
I think the cause is the OverpaintablePanel.getMinimumSize() method. In later versions the method was overwritten by child classes (e.g. in StackDockStation.Background class).
I was not able to find a reliable reproduction scenario in later versions of the library but I think I saw it happening once or twice :slight_smile:

package test;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import bibliothek.extension.gui.dock.theme.flat.FlatStationPaint;
import bibliothek.gui.dock.common.CControl;
import bibliothek.gui.dock.common.CGrid;
import bibliothek.gui.dock.common.DefaultSingleCDockable;
import bibliothek.gui.dock.common.theme.CEclipseTheme;
import bibliothek.gui.dock.common.theme.ThemeMap;

public class Dock111p7e
{
  public static void main(String[] args)
  {
    // setting up frame and controller
    JFrame frame = new JFrame();
    CControl control = new CControl(frame);
    control.setTheme(ThemeMap.KEY_ECLIPSE_THEME);

    ((CEclipseTheme)control.getController().getTheme()).intern().setPaint(new FlatStationPaint());
    
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(700, 700);

    DefaultSingleCDockable red = create(control, "Red", Color.RED);
    DefaultSingleCDockable green = create(control, "Green", Color.GREEN);
    DefaultSingleCDockable blue = create(control, "Blue", Color.BLUE);

    CGrid grid = new CGrid(control);
    grid.add(0, 0, 5, 5, red);
    grid.add(0, 0, 5, 5, green);
    grid.add(0, 0, 5, 5, blue);

    control.getContentArea().deploy(grid);
    frame.getContentPane().add(control.getContentArea(), BorderLayout.CENTER);
    frame.setVisible(true);
  }

  public static DefaultSingleCDockable create(CControl control, String title, Color color)
  {
    final JPanel panel = new JPanel();
    panel.setOpaque(true);
    panel.setBackground(color);

    final DefaultSingleCDockable singleDockable = new DefaultSingleCDockable(title, title, panel);
    singleDockable.setCloseable(true);

    return singleDockable;
  }

}```

:frowning:

I’ll try out your code mmodelski, and I’ll have a look at the method you mentioned - but not before the weekend.

Hi Beni,

I tried p13 and it still freezes sometimes (only in java8).
I could not find a reliable reproduction and I can only reproduce it in my application so other things may cause it…
I found this however:
https://bugs.openjdk.java.net/browse/JDK-8061636
It is a bug in openjdk 8 but I can also reproduce it in standard java 8.
The symptoms look very similar…

kind regards,
Maciej Modelski

Too bad there is no workaround for the bug in the JDK, I hope it gets fixed.