免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 839 | 回复: 0
打印 上一主题 下一主题

JAVA连接Access数据库的实现 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-07-06 15:07 |只看该作者 |倒序浏览
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AudioPlay extends JApplet {
  private AudioClip sound1, sound2, currentSound;
  private JButton playSound, loopSound, stopSound;
  private JComboBox chooseSound;
  public void init(){
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    String choices[] = { "main", "spacemusic" };
    chooseSound = new JComboBox( choices );
    chooseSound.addItemListener( new ItemListener() {
      public void itemStateChanged( ItemEvent e )
      {
        currentSound.stop();
        currentSound =chooseSound.getSelectedIndex() == 0 ? sound1 : sound2;
      }
    }); // end addItemListener method call
    container.add( chooseSound );
    ButtonHandler handler = new ButtonHandler();
    playSound = new JButton( "Play" );
    playSound.addActionListener( handler );
    container.add( playSound );
    loopSound = new JButton( "Loop" );
    loopSound.addActionListener( handler );
    container.add( loopSound );
    stopSound = new JButton( "Stop" );
    stopSound.addActionListener( handler );
    container.add( stopSound );
    sound1 = getAudioClip( getDocumentBase(), "main.wav" );
    sound2 = getAudioClip( getDocumentBase(), "spacemusic.au" );
    currentSound = sound1;
  } // end method init
  public void stop(){
    currentSound.stop();
  }
  private class ButtonHandler implements ActionListener {
    public void actionPerformed( ActionEvent actionEvent )
    {
      if ( actionEvent.getSource() == playSound )
        currentSound.play();
      else if ( actionEvent.getSource() == loopSound )
        currentSound.loop();
      else if ( actionEvent.getSource() == stopSound )
        currentSound.stop();
    }
  }
}


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/21219/showart_137198.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP