1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| private Main() throws IOException {
setLocationRelativeTo(null);
setUndecorated(false);
setSize(616, 349);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Action action = new Action();
setContentPane(action);
setIconImage(new ImageIcon("src/images/icone.gif").getImage());
setTitle("R1beLlu");
setLocationRelativeTo(null);
setAlwaysOnTop(true);
setResizable(false);
setUndecorated(true);
setBackground(new Color(0, 0, 0, 0));
setVisible(true);
MouseListener.executorService.execute(() -> {
while (!MouseListener.executorService.isShutdown()) {
action.repaint(); //le probleme est ici
try {
Thread.sleep(50);
} catch (Exception e) {
e.printStackTrace();
}
}
});
try {
setupConfigs();
setupEvents();
} catch (NativeHookException ex) {
System.exit(1);
}
addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
posX = e.getX();
posY = e.getY();
}
});
addMouseMotionListener(new MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
int depX = e.getX() - posX;
int depY = e.getY() - posY;
setLocation(getX() + depX, getY() + depY);
}
}); |
Partager