关于JApplet音频大小的问题 我最近写了一个JApplet程序,播放wav音频的。但只能播放一个,它有125K,其他两个都超过了400k,请问是大小的限制导致了另外两个不能播放吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.applet.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class AudioPlayer extends JApplet { private AudioClip[] sounds; private AudioClip currentSound; // 当前歌曲 private JButton playSound, loopSound, stopSound; private JComboBox chooseSound; public void init() { Container c = getContentPane(); c.setLayout(new FlowLayout()); String choices[] = { "call.wav", "tiaopi.wav", "ffy.mp3" }; // 歌曲名 chooseSound = new JComboBox(choices); chooseSound.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { currentSound.stop(); currentSound = sounds[chooseSound.getSelectedIndex()]; } }); c.add(chooseSound); ButtonHandler h = new ButtonHandler(); playSound = new JButton("Play"); playSound.addActionListener(h); c.add(playSound); loopSound = new JButton("Loop"); loopSound.addActionListener(h); c.add(loopSound); stopSound = new JButton("Stop"); stopSound.addActionListener(h); c.add(stopSound); sounds = new AudioClip[choices.length]; // 加载音频文件,创建AudioClip对象 for (int i = 0; i < choices.length; i++) sounds[i] = getAudioClip(getDocumentBase(), choices[i]); currentSound = sounds[0]; } public void stop() { currentSound.stop(); } private class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { if (e.getSource() == playSound) currentSound.play(); else if (e.getSource() == loopSound) currentSound.loop(); else if (e.getSource() == stopSound) currentSound.stop(); } }} 程序测试能播放多个的AudioClip不支持播放mp3格式的,想要支持可以试试jmf 呵呵 我忘了删掉mp3格式的文件了,原来是只能播放一个wav,现在好了!谢啦! 最近写了一个用户验证密码的程序,其功能如下:输入用户名和密码,然后提交,只有在密码位数大于8位切有数字的时候,才输出Thank you Your password meets the security policy 否则输出Sorry Your password does not meet the security policy 可是我的不知道怎么了,两个竟然同时输出了!各位大虾帮帮忙啊!谢啦!login.html文件如下:<html><head><title>A Siple Login Page</title></head><body><p>Please Login:<form action=login.jsp method=post><p>User Name:<input type=text name=usernameField><p>Password:<input type=text name=passwordField><p><input type=SUBMIT value=Submit></form></body></html>login.jsp文件如下:<html><head><title>A Simple Jsp That Verifies Password Policy</title></head><body><%! final static int MIN_PSWD_LEN=8;static boolean verifyPasswordLength(String password){if(password.length()<MIN_PSWD_LEN)return false;return true;}static boolean verifyPasswordHasDigit(String password){for(int i=0;i<password.length();i++)if(Character.isDigit(password.charAt(i))) return true;return false;}static boolean verifyPasswordPolicy(String password){if(verifyPasswordLength(password)&&verifyPasswordHasDigit(password))return true;else return false;}%><%String password=request.getParameter(passwordField);if(verifyPasswordPolicy(password)){%><p>Thank you<p>Your password meets the security policy<%}else{%><p>Sorry<p>Your password does not meet the security policy<p><a href="login.html">Please Try Again</a><%}%></body></html> Java 使用smtp协议发送邮件 jar文件如何解压缩? static final int 表示含义 菜鸟问题,高手来解决!! 简单问题大家帮帮忙,在线等哦! 菜鸟紧急求助!! 哇,有美女看呀.... JTree的奇怪问题 帮忙!谢过! 请问哪里有加密算法的源代码(md5等)(40分,找到即送) 随机输出数字1-54,却只有53个。各位兄弟帮着看看。欢迎拍砖! 今天学习线程 其中 守护线程daemon有什么用处?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class AudioPlayer extends JApplet {
private AudioClip[] sounds; private AudioClip currentSound; // 当前歌曲 private JButton playSound, loopSound, stopSound; private JComboBox chooseSound; public void init() {
Container c = getContentPane();
c.setLayout(new FlowLayout());
String choices[] = { "call.wav", "tiaopi.wav", "ffy.mp3" }; // 歌曲名
chooseSound = new JComboBox(choices);
chooseSound.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
currentSound.stop();
currentSound = sounds[chooseSound.getSelectedIndex()];
}
});
c.add(chooseSound);
ButtonHandler h = new ButtonHandler();
playSound = new JButton("Play");
playSound.addActionListener(h);
c.add(playSound);
loopSound = new JButton("Loop");
loopSound.addActionListener(h);
c.add(loopSound);
stopSound = new JButton("Stop");
stopSound.addActionListener(h);
c.add(stopSound);
sounds = new AudioClip[choices.length];
// 加载音频文件,创建AudioClip对象
for (int i = 0; i < choices.length; i++)
sounds[i] = getAudioClip(getDocumentBase(), choices[i]);
currentSound = sounds[0];
} public void stop() {
currentSound.stop();
} private class ButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == playSound)
currentSound.play();
else if (e.getSource() == loopSound)
currentSound.loop();
else if (e.getSource() == stopSound)
currentSound.stop();
}
}
}
AudioClip不支持播放mp3格式的,想要支持可以试试jmf
输入用户名和密码,然后提交,只有在密码位数大于8位切有数字的时候,才输出Thank you Your password meets the security policy 否则输出Sorry Your password does not meet the security policy 可是我的不知道怎么了,两个竟然同时输出了!各位大虾帮帮忙啊!谢啦!login.html文件如下:
<html>
<head><title>A Siple Login Page</title></head>
<body>
<p>Please Login:
<form action=login.jsp method=post>
<p>User Name:<input type=text name=usernameField>
<p>Password:<input type=text name=passwordField>
<p><input type=SUBMIT value=Submit>
</form>
</body>
</html>
login.jsp文件如下:
<html>
<head>
<title>A Simple Jsp That Verifies Password Policy</title>
</head>
<body>
<%! final static int MIN_PSWD_LEN=8;
static boolean verifyPasswordLength(String password){
if(password.length()<MIN_PSWD_LEN)return false;
return true;
}static boolean verifyPasswordHasDigit(String password){
for(int i=0;i<password.length();i++)
if(Character.isDigit(password.charAt(i))) return true;
return false;
}static boolean verifyPasswordPolicy(String password){
if(verifyPasswordLength(password)&&verifyPasswordHasDigit(password))
return true;
else
return false;
}
%><%String password=request.getParameter(passwordField);
if(verifyPasswordPolicy(password)){%>
<p>Thank you
<p>Your password meets the security policy
<%}else{%>
<p>Sorry
<p>Your password does not meet the security policy
<p><a href="login.html">Please Try Again</a>
<%}%>
</body>
</html>