?? noisybutton.java
字號:
//file: NoisyButton.javaimport java.applet.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class NoisyButton extends JFrame { public NoisyButton(final AudioClip sound) { // set up the frame setTitle("NoisyButton"); addWindowListener(new WindowAdapter( ) { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(200, 200); setLocation(100, 100); // set up the button JButton button = new JButton("Woof!"); button.addActionListener(new ActionListener( ) { public void actionPerformed(ActionEvent e) { sound.play( ); } }); getContentPane( ).setBackground(Color.pink); getContentPane().setLayout(new GridBagLayout( )); getContentPane( ).add(button); setVisible(true); } public static void main(String[] args) throws Exception { java.io.File file = new java.io.File("bark.aiff"); AudioClip sound = Applet.newAudioClip(file.toURL( )); new NoisyButton(sound); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -