出于某种原因声音,我添加到播放时,它悬停在一个按钮或标签上无法正常工作,它只播放一次,第一个按钮或标签悬停在那里,然后再也不会。 / p>
我怎样才能让它在每次盘旋时播放?
Clip MouseHover = null;
public Login()
{
initComponents();
try
{
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("src\\Music\\MouseHover.wav").getAbsoluteFile());
MouseHover = AudioSystem.getClip( );
MouseHover.open(audioInputStream);
}
catch(Exception ex)
{
System.out.println(ex);
}
}
private void ExitMouseClicked(java.awt.event.MouseEvent evt) {
System.exit(0);
}
private void MinimizeMouseClicked(java.awt.event.MouseEvent evt) {
this.setState(JFrame.ICONIFIED);
}
private void ForgotPasswordMouseClicked(java.awt.event.MouseEvent evt) {
}
private void MinimizeMouseEntered(java.awt.event.MouseEvent evt) {
Minimize.setBackground(new Color(149,165,166));
MouseHover.loop(0);
}
private void MinimizeMouseExited(java.awt.event.MouseEvent evt) {
Minimize.setBackground(new Color(108,122,137));
}
private void ExitMouseEntered(java.awt.event.MouseEvent evt) {
Exit.setBackground(new Color(149,165,166));
MouseHover.loop(0);
}
答案 0 :(得分:0)
private void MinimizeMouseEntered(java.awt.event.MouseEvent evt) {
Minimize.setBackground(new Color(149,165,166));
MouseHover.loop(1);
}
private void MinimizeMouseExited(java.awt.event.MouseEvent evt) {
Minimize.setBackground(new Color(108,122,137));
}
private void ExitMouseEntered(java.awt.event.MouseEvent evt) {
Exit.setBackground(new Color(149,165,166));
MouseHover.loop(1);
}