Swing/AuditoryCues のバックアップの現在との差分(No.13)
- バックアップ一覧
- 差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/AuditoryCues へ行く。
- 1 (2008-05-26 (月) 17:13:17)
- 2 (2008-06-26 (木) 13:59:57)
- 3 (2008-10-08 (水) 17:25:29)
- 4 (2008-11-21 (金) 11:58:11)
- 5 (2009-01-08 (木) 15:58:36)
- 6 (2010-12-12 (日) 23:21:21)
- 7 (2014-10-02 (木) 03:52:59)
- 8 (2015-11-06 (金) 04:15:10)
- 9 (2016-05-26 (木) 14:33:35)
- 10 (2017-08-17 (木) 14:21:43)
- 11 (2017-11-02 (木) 15:31:07)
- 12 (2018-02-21 (水) 15:20:06)
- 13 (2018-11-08 (木) 17:48:07)
- 14 (2019-05-07 (火) 19:24:05)
- 15 (2021-02-05 (金) 08:28:39)
- 16 (2024-03-30 (土) 23:37:31)
- 追加された行はこの色です。
- 削除された行はこの色です。
--- category: swing folder: AuditoryCues title: AuditoryCuesでイベント音を設定する tags: [UIManager, AuditoryCues, Sound, JOptionPane] author: aterai pubdate: 2008-05-26T17:13:17+09:00 description: UIManagerにAuditoryCues.playListを設定して、ダイアログが開いた時の警告音などを鳴らします。 image: https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTHzQ8XbXI/AAAAAAAAARw/-TGnQ_tvnnM/s800/AuditoryCues.png --- * 概要 [#summary] `UIManager`に`AuditoryCues.playList`を設定して、ダイアログが開いた時の警告音などを鳴らします。 #download(https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTHzQ8XbXI/AAAAAAAAARw/-TGnQ_tvnnM/s800/AuditoryCues.png) * サンプルコード [#sourcecode] #code(link){{ Object[] optionPaneAuditoryCues = { "OptionPane.errorSound", "OptionPane.informationSound", "OptionPane.questionSound", "OptionPane.warningSound" "OptionPane.errorSound", "OptionPane.informationSound", "OptionPane.questionSound", "OptionPane.warningSound" }; //UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.allAuditoryCues")); //UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.defaultCueList")); //UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.noAuditoryCues")); // UIManager.put( // "AuditoryCues.playList", // UIManager.get("AuditoryCues.allAuditoryCues")); // UIManager.put( // "AuditoryCues.playList", // UIManager.get("AuditoryCues.defaultCueList")); // UIManager.put( // "AuditoryCues.playList", // UIManager.get("AuditoryCues.noAuditoryCues")); UIManager.put("AuditoryCues.playList", optionPaneAuditoryCues); }} * 解説 [#explanation] 上記のサンプルでは、デフォルトではすべて再生しないように設定されている聴覚フィードバックを、`JOptionPane`でダイアログを開いた場合は有効になるように変更しています。 上記のサンプルでは、デフォルトではすべて再生しないように設定されている聴覚フィードバックを、`JOptionPane`でダイアログを開いた場合のみ有効になるように変更しています。 - `showMessageDialog1` -- `LookAndFeel`デフォルトの音が鳴る(`LookAndFeel`にデフォルトの音が無い場合は鳴らない) -- `WindowsLookAndFeel`では、「コントロールパネル」「サウンドとオーディオデバイスのプロパティ」で、プログラムイベントが設定されている場合は音が鳴る - `showMessageDialog2` -- 別途用意した`wav`ファイルを再生する -- `UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.noAuditoryCues"))`として、二重に鳴らないように制限 ---- `MetalLookAndFeel`や`MotifLookAndFeel`では、以下のようにすることで、`MessageDialog`のイベント音を変更することも出来ます。 - `MetalLookAndFeel`や`MotifLookAndFeel`では以下のように`MessageDialog`のイベント音の変更が可能 #code{{ UIManager.put("OptionPane.informationSound", "/example/notice2.wav"); }} * 参考リンク [#reference] - [https://docs.oracle.com/javase/jp/8/docs/technotes/guides/swing/1.4/SwingChanges.html#bug4290988 Swingコンポーネントの音声フィードバック - Java™ SE 1.4でのSwingの変更点および新機能] - [https://www.ibm.com/developerworks/jp/java/library/j-mer0730/ Merlinの魔術: Swingのオーディオ] - [http://www.taitaistudio.com/wav/ "taitai studio" フリーWav素材集] - [[Beep音を鳴らす>Swing/Beep]] - [[MIDIファイルの演奏>Swing/MidiSystem]] - [[Wavファイルの演奏>Swing/Sound]] * コメント [#comment] #comment #comment