mirror of
https://github.com/anas-elgarhy/Ayah-intellij.git
synced 2024-08-15 00:43:43 +00:00
😆 Close the player when closing the details dialog 💙
This commit is contained in:
parent
d983c475a2
commit
decfa29628
1 changed files with 11 additions and 3 deletions
|
@ -87,22 +87,30 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
|
|||
}
|
||||
});
|
||||
|
||||
buttonCancel.addActionListener(l -> dispose());
|
||||
buttonCancel.addActionListener(l -> close());
|
||||
|
||||
// call onCancel() when cross is clicked
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
// call onCancel() on ESCAPE
|
||||
contentPane.registerKeyboardAction(l -> dispose(),
|
||||
contentPane.registerKeyboardAction(l -> close(),
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
|
||||
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
}
|
||||
|
||||
private void close() {
|
||||
if (isPlaying) {
|
||||
audioPlayer.stop();
|
||||
audioPlayer = null;
|
||||
}
|
||||
dispose();
|
||||
}
|
||||
|
||||
private void playOrNot() {
|
||||
if (autoPlayCheckBox.isSelected()) {
|
||||
audioPlayer.stop();
|
||||
|
|
Loading…
Reference in a new issue