Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Swing - How to sound beep before any JOptionPane?

Whenever i show a JOptionPane in my Swing application i fire a beep before it like this :

Toolkit.getDefaultToolkit().beep();
JOptionPane.showMessageDialog( myFrame, "Message", "Title", JOptionPane.INFORMATION_MESSAGE );

Is there a way to apply the first line automatically to any JOptionPane in case i forgot to write it in code ?

like image 576
Brad Avatar asked Dec 21 '10 11:12

Brad


2 Answers

You could create your own class which has a static method showMessageDialogAndBeep() which calls JOptionPane.showMessageDialog and beeps before.

like image 194
atamanroman Avatar answered Oct 13 '22 16:10

atamanroman


void showMessageDialog(Component pC, Object m, String t, int mT) { Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog( pC, m,t,mT); }

like image 38
k_zaur_k Avatar answered Oct 13 '22 16:10

k_zaur_k