FlapDockStation on second monitor goes in wrong direction

I have a FlapDockStation pinned to the West side of a border layout. When my application is moved to my second monitor, the FlapDockStation changes which direction the flaps pop out and opens outside to the left of the main application window instead of overlaying on top.

I imagine there is some code somewhere that make the flaps open towards the center of the monitor if they are off screen, but doesn’t account for a second monitor.

I am running on Linux Mint Debian Edition using NVidia TwinView for multi-monitor support.

Yes there is some code doing that. The code uses „Toolkit.getDefaultToolkit().getScreenSize();“ to find the size of the screen - apparently the result of that method is not enough. Since I’m lacking a second monitor I cannot repair this issue (well I could try, but testing is really hard…). If you feel like contributing to an open source project, have a look at FlapDockStation.selfSetDirection :wink:

In Common the feature is disabled (actually I don’t like it much), and you can do the same in your application by calling:

station.setAutoDirection( false );
station.setDirection( FlapDockStation.Direction.EAST );```


[edit: of course the real solution would be to use Common, in which case you would never have encountered this feature]

Thanks for the tip. Turns out that this actually works correctly on Nvidia twinview since twinview simulates a single display, it just wasn’t the behavior I expected. Setting auto direction manually was the desired behavior. Still, people with multi monitors might run into the issue. I found a fix that should work for any multi monitor setup.

In FlapDockStation.java selfSetDirection() replace


Dimension size = Toolkit.getDefaultToolkit().getScreenSize();

with


Rectangle2D screen = new Rectangle2D.Double();
GraphicsEnvironment localGE = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (GraphicsDevice gd : localGE.getScreenDevices()){
    for (GraphicsConfiguration graphicsConfiguration : gd.getConfigurations()){
        Rectangle.union(screen, graphicsConfiguration.getBounds(), screen);
    }
}
Dimension size = screen.getBounds().getSize();

Hm, I think pointing to the center of the current screen would be better. But as I said: I don’t like the feature anyways :wink: