Dialog () { if (myPickerFrame == null) { Window owner = SwingUtilities.getWindowAncestor(myParent); if (owner instanceof Dialog) { myPickerFrame = new JDialog((Dialog)owner); } else if (owner instanceof Frame) { myPickerFrame = new JDialog((Frame)owner); } else { myPickerFrame = new JDialog(new JFrame()); } myPickerFrame.setTitle("intellijPickerDialog"); } myPickerFrame.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { e.consume(); pickAndClose(); } @Override public void mouseClicked(MouseEvent e) { e.consume(); } }); myPickerFrame.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE -> cancelPipette(); case KeyEvent.VK_ENTER -> pickAndClose(); } } }); myPickerFrame.setUndecorated(true); myPickerFrame.setAlwaysOnTop(canUseMacPipette()); JRootPane rootPane = myPickerFrame.getRootPane(); rootPane.putClientProperty("Window.shadow", Boolean.FALSE); return myPickerFrame; }