如何在按住按钮时实现提示音
各位同胞如何在按住按钮时实现提示音,是这个语句吗?
Toolkit.getDefaultToolkit().beep();
只有一种声音吗?
还有没有其他的声音?!
/**
* Swing中提示音示例
* By Eastsun
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AudioFrame extends JFrame {
public AudioFrame() {
super(\"AudioFrame\");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new FlowLayout());
setSize(new Dimension(320,240));
add(new JButton(new AbstractAction(\"确定对话框\"){
public void actionPerformed(ActionEvent e) {
int result = JOptionPane.showConfirmDialog(AudioFrame.this, \"确认?\");
if (result == JOptionPane.YES_OPTION) JOptionPane.showMessageDialog(AudioFrame.this, \"确认\");
else JOptionPane.showMessageDialog(AudioFrame.this, \"取消\");
}
}));
add(new JButton(new AbstractAction(\"消息对话框\"){
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(AudioFrame.this, \"Hello,Swing!\");
}
}));
pack();
}
public static void main(String args[]) {
UIManager.put(\"AuditoryCues.playList\",UIManager.get(\"AuditoryCues.allAuditoryCues\"));
SwingUtilities.invokeLater(new Runnable(){
public void run(){
new AudioFrame().setVisible(true);
}
});
}
}