I have a method which brings up a transparent window overlay so I can indicate corner points of a rectangular onscreen area via clicks.
public Point getClickPoint(){ JFrame frame = new JFrame(""); MyMouseListener mouseL = new MyMouseListener(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setUndecorated(true); makeTranslucent(frame, Float.valueOf(0.40f)); frame.setSize(toolkit.getScreenSize()); frame.setVisible(true); frame.addMouseListener(mouseL); while(!mouseL.done){ try { Thread.sleep(4); } catch (InterruptedException e) { e.printStackTrace(); } } } When I call this in a normal way it works fine, but if I call it by a button press, then it hangs, doesn't register clicks and eventually freezes.
Button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { getClickPoint(); } } Is this something to do with the fact this is called originally by an action listener?