資源簡介
光盤出租管理系統,Java連接數據庫,結合SQL sever ,對SQL語言的了解和掌握,對數據庫的管理(主要是安全性方面)的了解
代碼片段和文件信息
package?CD;
import?java.applet.*;??
import?java.awt.*;??
import?java.awt.event.*;??
import?java.net.*;??
??
import?javax.swing.*;??
import?java.io.File;??
??
public?class?AudioPlayDemo?extends?Jframe?implements?ActionListener{??
????boolean?looping?=?false;???
????File?file1?=?new?File(“ólafur?Arnalds?-?3055?-?純音樂版.wav“);??
????AudioClip?sound1;??
????AudioClip?chosenClip;??
??
????JButton?playButton?=?new?JButton(“播放“);???
????JButton?loopButton?=?new?JButton(“循環播放“);??????
????JButton?stopButton?=?new?JButton(“停止“);???
????JLabel?status?=?new?JLabel(““);???
????JPanel?controlPanel?=?new?JPanel();???
????Container?container?=?getContentPane();???
??
????public?AudioPlayDemo()?{???
????????try?{??
????????????sound1?=?applet.newAudioClip(file1.toURL());??
????????????chosenClip?=?sound1;??
????????}?catch(OutOfMemoryError?e){??
????????????System.out.println(“內存溢出“);??
????????????e.printStackTrace();??
????????}?catch(Exception?e){??
????????????e.printStackTrace();??
????????}??
??
????????playButton.addActionListener(this);??
????????loopButton.addActionListener(this);??
????????stopButton.addActionListener(this);??
????????stopButton.setEnabled(false);???
??
????????controlPanel.add(playButton);??
????????controlPanel.add(loopButton);??
????????controlPanel.add(stopButton);??
??
????????container.add(controlPanel?BorderLayout.CENTER);??
????????container.add(status?BorderLayout.SOUTH);??
??
????????setSize(300?130);???
????????this.setLocation(100100);//設置窗口在屏幕正中間顯示??
??????????
????????settitle(“音樂播放“);??
????????setVisible(true);??
????????setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);?//關閉窗口時退出程序??
????}??
??
????public?void?actionPerformed(ActionEvent?event)?{??
????????if?(chosenClip?==?null)?{??
????????????status.setText(“聲音未載入“);??
????????????return;???
????????}??
????????object?source?=?event.getSource();?//獲取用戶洗滌激活的按鈕??
??
????????if?(source?==?playButton?)?{??
????????????stopButton.setEnabled(true);???
????????????loopButton.setEnabled(true);???
????????????chosenClip.play();???
????????????status.setText(“正在播放“);??
????????}??
??
????????if?(source?==?loopButton)?{??
????????????looping?=?true;??
????????????chosenClip.loop();???
????????????loopButton.setEnabled(false);???
????????????stopButton.setEnabled(true);???
????????????status.setText(“正在循環播放“);???
????????}??
????????if?(source?==?stopButton)?{??
????????????if?(looping)?{??
????????????????looping?=?false;??
????????????????chosenClip.stop();???
????????????????loopButton.setEnabled(true);??
????????????}?else?{??
????????????????chosenClip.stop();??
????????????}??
????????????stopButton.setEnabled(false);???
????????????status.setText(“停止播放“);??
????????}??
????}
}
????
//????public?static?void?main(String?s[])?{??
//????????new?AudioPlayDemo();???
//????}??
//}?
- 上一篇:進銷存java源代碼分享
- 下一篇:Android 超好用反編譯工具
評論
共有 條評論