I have created a side class to help me manage functions that i reuses in all of my GUI JFrames
i am using an undecorated JFrame, and i have added a simple functions to be able to drag it around
public class SideFunctions {
static int xMouse, yMouse;
public static void frameDragMouseDragged(JFrame frame, MouseEvent e) {
int x = e.getXOnScreen();
int y = e.getYOnScreen();
frame.setLocation(x - xMouse, y - yMouse);
}
public static void frameDragMouseClicked(JFrame frame, MouseEvent e) {
xMouse = e.getX();
yMouse = e.getY();
}
inside my EntranceScreen class which extends JFrame i try to do this
private void createFrameDragLabel() {
frameDrag = new JLabel();
frameDrag.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseDragged(MouseEvent arg0) {
SideFunctions.frameDragMouseDragged(this, arg0);
}
});
frameDrag.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
SideFunctions.frameDragMouseClicked(this, arg0);
}
});
frameDrag.setBounds(0, 0, 700, 400);
}
i want 'this' to refer to the JFrame instance but it is refering to the MouseMotionAdapter / MouseAdapter, how can i pass the JFrame object itself?