Undecorated JFrame can't be dragged to the top of the Ubuntu screen properly
<p>I have an undecorated <code>JFrame</code> with <code>JPanel</code> which is for dragging the window on the screen. It works, but when I want to drag it completely to the top of the screen it can't go there. There is space between window and top bar. I'm enclosing the screenshot and code. I'm using Ubuntu 14.04. Is there a way how to fix that?</p>

<p><a href="https://i.stack.imgur.com/vIDsn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vIDsn.png" alt="Look at that space"></a></p>

<pre><code>public class Window extends JFrame {

    private int mouse_x_offset;
    private int mouse_y_offset;

    public Window() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(250, 250);

        JPanel panel = new JPanel();
        panel.setBackground(Color.BLACK);

        setUndecorated(true);
        setVisible(true);

        panel.addMouseMotionListener(new PanelListener());
        panel.addMouseListener(new PanelListener());

        add(panel);
    }

    class PanelListener implements MouseMotionListener, MouseListener {

        @Override
        public void mouseDragged(MouseEvent e) {
            int x = e.getXOnScreen();
            int y = e.getYOnScreen();

            setLocation(x - mouse_x_offset, y - mouse_y_offset);
        }

        @Override
        public void mouseMoved(MouseEvent e) {

        }

        @Override
        public void mouseClicked(MouseEvent e) {

        }

        @Override
        public void mousePressed(MouseEvent e) {
            mouse_x_offset = e.getX();
            mouse_y_offset = e.getY();
        }

        @Override
        public void mouseReleased(MouseEvent e) {

        }

        @Override
        public void mouseEntered(MouseEvent e) {

        }

        @Override
        public void mouseExited(MouseEvent e) {

        }
    }

    public static void main(String[] args) {
        Window window = new Window();
    }

}
</code></pre>