大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

关于唱吧的java代码 唱吧源代码

求解决办法java.lang.classcastException:java.util.

你的软件出现BUG了,很明显你输入了特殊内容或者本身程序没处理好一些常用操作,java.lang.classcastException:java.util.LinkedList专业术语就是类造型异常,如果你不是专业人员的话,建议找开发人员看看哈

10年积累的成都做网站、成都网站制作经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先做网站设计后付款的网站建设流程,更有临清免费网站建设让你可以放心的选择与我们合作。

如何在JAVA里调用C++的程序呢

可以用JNI,JNI是Java Native Interface的缩写,它提供了若干的API实现了Java和其他语言的通信(主要是CC++)。

跪求java 音乐播放的代码啊,完美运行的就行

import java.applet.Applet;

import java.applet.AudioClip;

import java.awt.AWTException;

import java.awt.Frame;

import java.awt.SystemTray;

import java.awt.TrayIcon;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.io.File;

import java.io.IOException;

import javax.imageio.ImageIO;

import javax.swing.*;

public class bofan_2 extends JFrame implements ActionListener

{

boolean looping=false;

File file1=null;

AudioClip sound1;

AudioClip chosenClip;

private JComboBox box1=null; //歌曲列表

private JButton butbofan=null; //播放

private JButton butboxhuan=null; //循环播放

private JButton buttinzi=null; //停止

private JButton butshan=null; //上一首

private JButton butzhantin=null; //暂停

private JButton butxia=null; //下一首

private TrayIcon trayIcon;//托盘图标

private SystemTray systemTray;//系统托盘

public bofan_2()

{

this.setSize(420,400);

this.setResizable(false);

this.setLocationRelativeTo(null);

this.setLayout(null);

box1=new JComboBox();

box1.addItem("伤心太平洋");

box1.addItem("劲爆的士高");

box1.addItem("老夫少妻");

box1.addItem("爱不再来");

box1.addItem("抽身");

box1.addItem("伤心城市");

box1.addItem("二零一二");

box1.addItem("精忠报国");

box1.addItem("秋沙");

box1.addItem("吻别");

box1.addItem("音乐疯起来");

box1.setBounds(10,20,150,20);

butbofan=new JButton("播放");

butbofan.addActionListener(this);

butbofan.setBounds(165,50,60,20);

butboxhuan=new JButton("循环播放");

butboxhuan.addActionListener(this);

butboxhuan.setBounds(230,50,90,20);

buttinzi=new JButton("停止");

buttinzi.setEnabled(false);

buttinzi.addActionListener(this);

buttinzi.setBounds(335,50,60,20);

butshan=new JButton("上一首");

butshan.addActionListener(this);

butshan.setBounds(165,90,80,20);

butzhantin=new JButton("暂停");

butzhantin.setEnabled(false);

butzhantin.addActionListener(this);

butzhantin.setBounds(250,90,60,20);

butxia=new JButton("下一首");

butxia.addActionListener(this);

butxia.setBounds(320,90,80,20);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.getContentPane().add(box1);

this.getContentPane().add(butbofan);

this.getContentPane().add(butboxhuan);

this.getContentPane().add(buttinzi);

this.getContentPane().add(butshan);

this.getContentPane().add(butzhantin);

this.getContentPane().add(butxia);

try {

UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel");

} catch (ClassNotFoundException e)

{

e.printStackTrace();

} catch (InstantiationException e)

{

e.printStackTrace();

} catch (IllegalAccessException e)

{

e.printStackTrace();

} catch (UnsupportedLookAndFeelException e)

{

e.printStackTrace();

}

setSize(450,450);

systemTray = SystemTray.getSystemTray();//获得系统托盘的实例

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

try {

trayIcon = new TrayIcon(ImageIO.read(new File("004.jpg")));

systemTray.add(trayIcon);//设置托盘的图标,0.gif与该类文件同一目录

}

catch (IOException e1)

{

e1.printStackTrace();

}

catch (AWTException e2)

{

e2.printStackTrace();

}

this.addWindowListener(

new WindowAdapter(){

public void windowIconified(WindowEvent e)

{

dispose();//窗口最小化时dispose该窗口

}

});

trayIcon.addMouseListener(new MouseAdapter()

{

public void mouseClicked(MouseEvent e){

if(e.getClickCount() == 2)//双击托盘窗口再现

setExtendedState(Frame.NORMAL);

setVisible(true);

}

});

this.setVisible(true);

}

public void actionPerformed(ActionEvent e)

{

Object source = e.getSource();

if (source== butbofan)

{

System.out.println((String) box1.getSelectedItem());

file1=new File((String) box1.getSelectedItem()+".wav");

butboxhuan.setEnabled(true);

buttinzi.setEnabled(true);

butzhantin.setEnabled(true);

butzhantin.setText("暂停");

try {

sound1 = Applet.newAudioClip(file1.toURL());

chosenClip = sound1;

} catch(OutOfMemoryError er){

System.out.println("内存溢出");

er.printStackTrace();

} catch(Exception ex){

ex.printStackTrace();

}

chosenClip.play();

this.setTitle("正在播放"+(String) box1.getSelectedItem());

}

if (source== butboxhuan)

{

file1=new File((String) box1.getSelectedItem()+".wav");

try {

sound1 = Applet.newAudioClip(file1.toURL());

chosenClip = sound1;

} catch(OutOfMemoryError er){

System.out.println("内存溢出");

er.printStackTrace();

} catch(Exception ex){

ex.printStackTrace();

}

looping = true;

chosenClip.loop();

butboxhuan.setEnabled(false);

buttinzi.setEnabled(true);

butzhantin.setText("暂停");

this.setTitle("正在循环播放"+(String) box1.getSelectedItem());

}

if (source== buttinzi)

{

if (looping)

{

looping = false;

chosenClip.stop();

butboxhuan.setEnabled(true);

butzhantin.setText("暂停");

} else {

chosenClip.stop();

}

buttinzi.setEnabled(false);

this.setTitle("停止播放");

}

if(source==butshan)

{

butzhantin.setText("暂停");

}

if(source==butzhantin)

{

buttinzi.setEnabled(false);

butzhantin.setText("继续");

if(source==butzhantin)

{

butzhantin.setText("暂停");

}

}

if(source==butxia)

{

butzhantin.setText("暂停");

}

}

public static void main(String[] args)

{

bofan_2 xx=new bofan_2();

}

}

/*

可以用加载声音文件的方法:

第一帧:mysound= new Sound();

mysound.attachSound(声音id名字);

ptime = 0;

播放按钮as:

on(release){

mysound.start(ptime);

}

暂停按钮as:

on(release){

ptime = mysound.position/1000;

mysound.stop();

}

*/

安卓手机唱吧登录显示recvfrom failer:ECONNRESET(Connection reset by peer)_ssid

Java代码

### The error occurred while setting parameters

### SQL: insert into SYS_SECURITY_RIGHT_SYSTEM( SYSRIGHT_ID, SYS_ORDER, SYS_NAME, SYS_MEMO ) values ( ?, ?, ?, ? )

### Cause: java.sql.SQLException: ORA-01400: 无法将 NULL 插入 ("SMARTCITY"."SYS_SECURITY_RIGHT_SYSTEM"."SYSRIGHT_ID")

]

在使用Mybatis主键自增长时,其要求使用Integer,使用〈selectKey〉时需要数据库中存在一条数据,不然回报上述错误。

Java代码

2013-06-19 09:27:56,109 [http-bio-8080-exec-1] DEBUG [org.mybatis.spring.SqlSessionUtils] - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1681460]

2013-06-19 09:27:56,119 [http-bio-8080-exec-1] DEBUG [org.mybatis.spring.transaction.SpringManagedTransaction] - JDBC Connection [org.apache.commons.dbcp.PoolableConnection@a1e9b0] will be managed by Spring

2013-06-19 09:27:56,119 [http-bio-8080-exec-1] DEBUG [dci.smartcity.operationsmanagement.dao.IOrgDAO.update] - ooo Using Connection [org.apache.commons.dbcp.PoolableConnection@a1e9b0]

2013-06-19 09:27:56,129 [http-bio-8080-exec-1] DEBUG [dci.smartcity.operationsmanagement.dao.IOrgDAO.update] - == Preparing: update SYS_SECURITY_ORG SET ORG_NAME= ?, ORG_PID=?, ORG_ORDER=?, ORG_MEMO=?, ORG_CREATETIME=?, ORG_CREATEUSER=? where ORG_ID = ?

2013-06-19 09:27:56,129 [http-bio-8080-exec-1] DEBUG [dci.smartcity.operationsmanagement.dao.IOrgDAO.update] - == Parameters: xx (String), 1(Integer), 2(Integer), dfd (String), 20121111(Integer), ??????? (String), 3(Integer)

2013-06-19 09:27:56,156 [http-bio-8080-exec-1] DEBUG [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator] - Unable to translate SQLException with Error code '12899', will now try the fallback translator

2013-06-19 09:27:56,159 [http-bio-8080-exec-1] DEBUG [org.springframework.jdbc.support.SQLStateSQLExceptionTranslator] - Extracted SQL state class '72' from value '72000'

2013-06-19 09:27:56,161 [http-bio-8080-exec-1] DEBUG [org.mybatis.spring.SqlSessionUtils] - Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1681460]

在更新时出现如上错误,

错误原因:由于oracle数据库中设置字符串长度为255时,当插入数据aaaaa未满时会以空格填充,在更新时,我们直接在字符串aaaaa后添加时,其位数超过255,在更新时不能成功,并报以上错误。

Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:

--- The error occurred in entity/TabB.xml.

--- The error occurred while applying a parameter map.

--- Check the tab_b.insert-InlineParameterMap.

--- Check the statement (update failed).

--- Cause: java.sql.SQLException: ORA-00942: 表或视图不存在

环境:数据库oracle11g,

ibatis的TabB.xml中对应数据库中的表,在运行时不能自动创建,所以只能手动在Oracle中创建表。

Java代码

java.lang.ExceptionInInitializerError

at tools.Test.clinit(Test.java:10)

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext-all.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\eclipsejuno\eclipse\workspaces\smartcity\smartcity-mybatis\target\classes\org\smartcity\db1\entity\TabAMapper.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for db1.taba.insert

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

at org.springframework.context.support.ClassPathXmlApplicationContext.init(ClassPathXmlApplicationContext.java:139)

at org.springframework.context.support.ClassPathXmlApplicationContext.init(ClassPathXmlApplicationContext.java:83)

at tools.ApplicationContextUtils.rebuildApplicationContext(ApplicationContextUtils.java:21)

at tools.ApplicationContextUtils.clinit(ApplicationContextUtils.java:12)

... 1 more

Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\eclipsejuno\eclipse\workspaces\smartcity\smartcity-mybatis\target\classes\org\smartcity\db1\entity\TabAMapper.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for db1.taba.insert

at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:462)

at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:336)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)

... 14 more

Caused by: java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for db1.taba.insert

at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)

at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)

at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:460)

... 17 more

Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for db1.taba.insert

at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:760)

at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:732)

at org.apache.ibatis.session.Configuration.addMappedStatement(Configuration.java:562)

at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:307)

at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:109)

at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)

at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:121)

at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:111)

... 19 more

求一个JAVA音乐播放器的源代码

import javax.media.ControllerEvent;

import javax.media.ControllerListener;

import javax.media.EndOfMediaEvent;

import javax.media.PrefetchCompleteEvent;

import javax.media.RealizeCompleteEvent;

import javax.media.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class MediaPlayer extends JFrame implements ActionListener,

ItemListener, ControllerListener {

String title;

Player player;

boolean first = true, loop = false;

Component vc, cc;

String currentDirectory=null;

// 构造函数,其中包括了设置响应窗口事件的监听器。

MediaPlayer(String title) {

super(title);

/* 关闭按钮的实现。。 */

addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

dispose();

}

public void windowClosed(WindowEvent e) {

if (player != null)

player.close();

System.exit(0);

}

});

// 调用程序菜单栏的方法成员完成菜单的布置

setupMenu();

setSize(400, 400);

setVisible(true);

}

// 本方法用以设置程序菜单栏

public void setupMenu() {

// 设置一个菜单

Menu f = new Menu("文件");

// 往设置的菜单添加菜单项

MenuItem mi = new MenuItem("打开");

f.add(mi);

mi.addActionListener(this);

f.addSeparator();

CheckboxMenuItem cbmi = new CheckboxMenuItem("循环", false);

cbmi.addActionListener(this);

f.add(cbmi);

f.addSeparator();

MenuItem ee = new MenuItem("退出");

ee.addActionListener(this);

f.add(ee);

f.addSeparator();

Menu l = new Menu("播放列表");

Menu c = new Menu("播放控制");

MenuItem move = new MenuItem("播放");

move.addActionListener(this);

c.add(move);

c.addSeparator();

MenuItem pause = new MenuItem("暂停");

pause.addActionListener(this);

c.add(pause);

c.addSeparator();

MenuItem stop = new MenuItem("停止");

stop.addActionListener(this);

c.add(stop);

c.addSeparator();

// 设置一个菜单栏

MenuBar mb = new MenuBar();

mb.add(f);

mb.add?;

mb.add(l);

// 将构造完成的菜单栏交给当前程序的窗口;

setMenuBar(mb);

}

// 动作时间响应成员;捕捉发送到本对象的各种事件;

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

String cufile, selectfile, currentDirectory;

if (e.getActionCommand().equals("退出")) {

// 调用dispose以便执行windowClosed

dispose();

return;

}

// 此事表明拥护选择了“播放”命令;

// 如果当前有一个文件可以播放则执行播放命令;

if (e.getActionCommand().equals("播放")) {

if (player != null) {

player.start();

}

return;

}

// 如果当前正在播放某一文件,则执行暂停;

if (e.getActionCommand().equals("暂停")) {

if (player != null) {

player.stop();

}

return;

}

// 停止命令的响应;

if (e.getActionCommand().equals("停止")) {

if (player != null) {

player.stop();

player.setMediaTime(new Time(0));

}

return;

}

// 用户选择要播放的媒体文件

if (e.getActionCommand().equals("打开")) {

FileDialog fd = new FileDialog(this, "打开媒体文件", FileDialog.LOAD);

// fd.setDirectory(currentDirectory);

2008-2-6 02:46 回复

肆方茉莉

62位粉丝

6楼

fd.setVisible(true);

// 如果用户放弃选择文件,则返回

if (fd.getFile() == null) {

return;

}

// 保存了所选文件的名称及其路径名称已被稍后使用

// 同时设置当前文件夹路径

selectfile = fd.getFile();

currentDirectory = fd.getDirectory();

cufile = currentDirectory + selectfile;

// 将用户选择的文件作为一个菜单项加入播放列表,该菜单项名为该文件名;

// 被点击后给出的命令串是该文件的全路径名

MenuItem mi = new MenuItem(selectfile);

mi.setActionCommand(cufile);

MenuBar mb = getMenuBar();

Menu m = mb.getMenu(2);

mi.addActionListener(this);

m.add(mi);

} else {

// 程序逻辑运行到次表示用户选择了一个“播放列表”中的媒体文件

// 此时可以通过如下动作获得该文件的全路径名

cufile = e.getActionCommand();

selectfile = cufile;

}

// 如果存在一个播放器,则先将其关闭,稍后再重新创建

// 创建播放器时需要捕捉一些异常

if (player != null) {

player.close();

}

try {

player = Manager.createPlayer(new MediaLocator("file:" + cufile));

} catch (Exception e2) {

System.out.println(e2);

return;

}/*

* catch(NoPlayerException e2){ System.out.println("不能找到播放器");

* return ; }

*/

if (player == null) {

System.out.println("无法创建播放器");

return;

}

first = false;

setTitle(selectfile);

// 设置处理播放控制器实际的对象;

/**/

player.addControllerListener(this);

player.prefetch();

}

// 菜单状态改变事件的响应函数;

public void itemStateChanged(ItemEvent arg0) {

// TODO Auto-generated method stub

}

public static void main(String[] args) {

// TODO Auto-generated method stub

new MediaPlayer("播放器");

}

// 调用绘图函数进行界面的绘制 // public void update() {

// }

// 绘图函数成员 //public void paint(Graphics g) {

// }

public void controllerUpdate(ControllerEvent e) {

// TODO Auto-generated method stub

Container tainer = getContentPane();

// 调用player.close()时ControllerClosedEvent事件出现

// 如果存在视觉部件,则该部件应该拆除(为了一致起见,我们对控制面版部件也执行同样的操作,下一次需要时再构造)

if (e instanceof ControllerClosedEvent) {

if (vc != null) {

remove(vc);

vc = null;

}

if (cc != null) {

remove(cc);

cc = null;

}

}

// 播放结束时,将播放指针置于文件之首,如果设定了循环播放,则再次启动播放器;

if (e instanceof EndOfMediaEvent) {

player.setMediaTime(new Time(0));

if (loop) {

player.start();

}

return;

}

// PrefetchCompletEvent事件发生后调用start,正式启动播放

if (e instanceof PrefetchCompleteEvent) {

player.start();

return;

}

// 本事件表示由于播放的资源已经确定;此时要将媒体的图形conmopnent

// 如果有显示出来,同时将播放器player的控制显示到窗口里;

if (e instanceof RealizeCompleteEvent) {

// 如果媒体中有图像,将对应图像component载入窗体;

vc = player.getVisualComponent();

if (vc != null)

tainer.add(vc, BorderLayout.CENTER);

// 将对应控制器component载入窗体;

cc = player.getControlPanelComponent();

cc.setBackground(Color.blue);

if (cc != null)

tainer.add(cc, BorderLayout.SOUTH);

// 有一些特殊媒体在播放时提供另外的控制手段,将控制器一并加入窗口;

/*

* gc=player.getGainControl(); gcc=gc.getControlComponent();

* if(gcc!=null) tainer.add(gcc,BorderLayout.NORTH);

*/

// 根据媒体文件中是否有图像,设定相应的窗口大小

if (vc != null) {

pack();

return;

} else {

setSize(300, 75);

setVisible(true);

return;

}

}

} }


网页名称:关于唱吧的java代码 唱吧源代码
当前路径:http://dzwzjz.com/article/dodgcjc.html
在线咨询
服务热线
服务热线:028-86922220
TOP