Skip to content

Instantly share code, notes, and snippets.

@k33ptoo
Created November 2, 2017 15:59
Show Gist options
  • Save k33ptoo/b2817b836665ce8207d706947516db98 to your computer and use it in GitHub Desktop.
Save k33ptoo/b2817b836665ce8207d706947516db98 to your computer and use it in GitHub Desktop.
Make underdecorated window movable in eclipse using WindowBuilder
JPanel panel = new JPanel();
panel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
xx = arg0.getX();
xy = arg0.getY();
}
});
panel.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent arg0) {
int x = arg0.getXOnScreen();
int y = arg0.getYOnScreen();
Home.this.setLocation(x - xx, y - xy);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment