zoukankan      html  css  js  c++  java
  • java 小综合

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.FileInputStream;
    import java.io.InputStream;

    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;

    import sun.audio.AudioPlayer;
    import sun.audio.AudioStream;

    public class Audio extends JFrame implements ActionListener{
     ImageIcon c1=new ImageIcon("D:\2.jpg");
     JLabel la;
     JButton start;
     AudioStream as;
     public Audio()
     {
      super("sdfhg");
      setLayout(null);
      setBounds(222, 220, 580, 620);
      
      
       try{ 
                 InputStream in = new FileInputStream ("D:\渴望.au");
                 //打开一个声音文件流作为输入
                 as = new AudioStream (in);
          }catch( Exception e){
                 e.printStackTrace();
         }             
      la=new JLabel();
      la.setIcon(c1);
      //la.setBounds(0, 0, 450, 468);
      start=new JButton("start");
      start.addActionListener(this);
      add(la);
      add(start);
      start.setBounds(500,0,50,30);
      la.setBounds(0,0,450,468);
      setVisible(true);
     }

     /**
      * @param args
      */
     public void actionPerformed(ActionEvent e) {
      // TODO Auto-generated method stub
      if(as==null)
       System.out.print("meizhao");
      Object ss=e.getSource();
      if(ss==start)
         AudioPlayer.player.stop(as);  
      
     }
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      Audio au=new Audio();

     }

    }

  • 相关阅读:
    洛谷 P5110 块速递推
    洛谷 P3868 [TJOI2009]猜数字
    Codeforces 343D Water Tree
    Codeforces 915E Physical Education Lessons
    洛谷 P2787 语文1(chin1)- 理理思维
    洛谷 P4344 [SHOI2015]脑洞治疗仪
    洛谷 P3338 [ZJOI2014]力
    【模板】珂朵莉树(ODT)(Codeforces 896C Willem, Chtholly and Seniorious)
    【模板】FFT
    Solution of CF911G Mass Change Queries
  • 原文地址:https://www.cnblogs.com/zhangdashuai/p/3468048.html
Copyright © 2011-2022 走看看