📄 frame1.java
字号:
package adio;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.io.*;import sun.audio.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author unascribed * @version 1.0 */public class Frame1 extends JFrame { private JPanel contentPane; private XYLayout xYLayout1 = new XYLayout(); private JButton jButton1 = new JButton(); private JButton jButton2 = new JButton(); private JButton jButton3 = new JButton(); AudioStream as; //Construct the frame public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); jButton1.setText("play"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); jButton2.setText("stop"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); jButton3.setText("continue"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton3_actionPerformed(e); } }); contentPane.add(jButton1, new XYConstraints(44, 113, 84, 30)); contentPane.add(jButton3, new XYConstraints(240, 113, 91, 30)); contentPane.add(jButton2, new XYConstraints(139, 113, 87, 30)); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jButton1_actionPerformed(ActionEvent e) { try{ File fl=new File("G:\\design\\same.mid"); InputStream in=new FileInputStream(fl);///ding.an beep.au return.au yahoo1.au G:\\jdk1.3.1\\demo\\applets\\TicTacToe\\audio\\return.au as=new AudioStream(in); }catch(Exception er){} if(as==null){System.out.println("sile");} else{ AudioPlayer.player.start(as);} } void jButton2_actionPerformed(ActionEvent e) {AudioPlayer.player.stop(as); } void jButton3_actionPerformed(ActionEvent e) {AudioPlayer.player.start(as); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -