⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 soundcontroller.java

📁 CroftSoft Code Library是一个开源的可移植的纯Java游戏库
💻 JAVA
字号:
     package com.croftsoft.apps.mars.controller;     import java.awt.*;     import java.awt.event.*;     import com.croftsoft.core.lang.NullArgumentException;     import com.croftsoft.core.media.sound.AudioClipCache;     import com.croftsoft.apps.mars.UserData;     /*********************************************************************     * Toggles sound.     *     * @version     *   2003-04-04     * @since     *   2003-04-02     * @author     *   <a href="http://www.croftsoft.com/">David Wallace Croft</a>     *********************************************************************/     public final class  SoundController       extends KeyAdapter     //////////////////////////////////////////////////////////////////////     //////////////////////////////////////////////////////////////////////     {     private final AudioClipCache  audioClipCache;     private final UserData        userData;     //////////////////////////////////////////////////////////////////////     //////////////////////////////////////////////////////////////////////     public  SoundController (       AudioClipCache  audioClipCache,       UserData        userData,       Component       component )     //////////////////////////////////////////////////////////////////////     {       NullArgumentException.check (         this.audioClipCache = audioClipCache );       NullArgumentException.check ( this.userData = userData );       component.addKeyListener ( this );       component.requestFocus ( );     }     //////////////////////////////////////////////////////////////////////     // interface KeyListener methods     //////////////////////////////////////////////////////////////////////     public void  keyPressed ( KeyEvent  keyEvent )     //////////////////////////////////////////////////////////////////////     {       if ( keyEvent.getKeyCode ( ) == KeyEvent.VK_S )       {         boolean  muted = !userData.isMuted ( );         userData.setMuted ( muted );         audioClipCache.setMuted ( muted );         System.out.println ( "Sound " + ( muted ? "off" : "on" ) );       }     }     //////////////////////////////////////////////////////////////////////     //////////////////////////////////////////////////////////////////////     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -