JFrame not moving
I want my JFrame to move despite disabling Decorrations.
i added a mouseListener after some googling but still didnt help.
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(new FlatDarkLaf());
} catch (Exception errorDesign) {
logError(errorDesign);
}
JFrame frame = new JFrame();
frame.setBounds(1600, 400, 500, 800);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.setVisible(true);
frame.addMouseListener(new MouseAdapter() {
private Point mouseOffset;
@Override
public void mousePressed(MouseEvent e) {
mouseOffset = e.getPoint();
}
@Override
public void mouseDragged(MouseEvent e) {
Point newLocation = e.getLocationOnScreen();
newLocation.translate(-mouseOffset.x, -mouseOffset.y);
frame.setLocation(newLocation);
}
});
}
someone who knows what i did wrong?
Comments
Post a Comment