import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.sound.midi.*;
import javax.swing.event.*;
public class BeatBox{
JFrame frame;
JPanel panel;
JList incomingList;
JTextField userMessege;
ArrayList<JCheckBox> checkboxList;
int nextNum;
Vector<String> listVector = new Vector<String>();
String userName;
ObjectOutputStream out;
ObjectInputStream in;
HashMap<String,boolean[]> otherSeqsMap = new HashMap<String,boolean[]>();
Sequencer sequencer;
Sequence sequence;
Sequence mySequence = null;
Track track;
String[] instrumentNames = {"Bass Drum","Closed Hi-Hat","Open Hi-Hat","Acoustic Snare","Crash Cymbal","Hand Clap","High Tom","Hi Bongo","Maracas","Whistle","Low Conga","Cowbell","Vibraslap","Low-mid Tom","High Agogo","Open Hi Conga"};
int[] instruments = {35,42,46,38,49,39,50,60,70,72,64,56,58,47,67,63};
public static void main(String[] args){
new BeatBox().startUp(args[0]);
}
/*
*网络连接部分
*/
public void startUp(String name){
userName = name;//打开到服务器的连接
try{
Socket sock = new Socket("127.0.0.1",4242);
out = new ObjectOutputStream(sock.getOutputStream());
in = new ObjectInputStream(sock.getInputStream());
Thread remote = new Thread(new RemoteReader());
remote.start();
}catch(Exception ex){
System.out.println("服务器无法连接");
}
setUpMidi();
buildGUI();
}
/*
*GUI部分
*/
public void buildGUI(){
frame = new JFrame("Cyber BeatBox");
BorderLayout layout = new BorderLayout();//API
JPanel background = new JPanel(layout);
background.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
checkboxList = new ArrayList<JCheckBox>();
Box buttonBox = new Box(BoxLayout.Y_AXIS);
JButton start = new JButton ("开始");
start.addActionListener(new MyStartListener());
buttonBox.add(start);
JButton stop = new JButton ("停止");
stop.addActionListener(new MyStopListener());
buttonBox.add(stop);
JButton up = new JButton ("节奏加快");
up.addActionListener(new MyupListener());
buttonBox.add(up);
JButton down = new JButton ("节奏变慢");
down.addActionListener(new MydownListener());
buttonBox.add(down);
JButton sendIt = new JButton("发送节奏");
sendIt.addActionListener(new MysendListener());
buttonBox.add(sendIt);
userMessege = new JTextField();
buttonBox.add(userMessege);
incomingList = new JList();
incomingList.addListSelectionListener(new MyListSelectionListener());
incomingList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane theList = new JScrollPane(incomingList);
buttonBox.add(theList);
incomingList.setListData(listVector); //API when it begin their has no data.
详细解决方案
了~这个程序运行的时候说 main里的数组越界~请高手帮忙看看,还有必须用-Xlint才能编译,为啥呢?小弟感激不尽
热度:7911 发布时间:2013-02-25 21:54:14.0
相关解决方案
- Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml解决办法
- 遇到一个有关问题,请知道者告诉在上,感激不尽
- 哪位高手能给个java程序读取xml的例子,感激不尽
- 大家介绍点好的webservices框架学习,感激不尽,该如何处理
- Exception in thread "main" java.lang.UnsupportedClassVersionError:有关问题
- 学习方向有关问题,希望各位大侠多给给宝贵意见!感激不尽
- 关于struts2 select标签的使用有关问题,请大家帮忙看看啦!感激不尽
- 急已经工作的哥们来看看给点建议~感激不尽!
- Exception in thread "main" java.lang.NullPointerException,该怎么处理
- 小弟我的程序中Exception in thread "main" java.lang.NullPointerException如何解决
- 用eclipse打包jar后运行,弹出异常could not find main class
- 运作提示:Exception in threa "main" java.lang.NoSuchMethodError:main
- Exception in thread "main" java.lang.UnsatisfiedLinkError: com.
- Exception in thread "main" java.lang.InstantiationError:
- myeclipse控制台程序运行报错:could not find the main class:org.apache.log4j.net.JMSSink.解决办法
- Exception in thread "main" java.lang.NoClassDefFound:HelloWorld,该怎么处理
- myeclipse控制台程序运作报错:could not find the main class:org.apache.log4j.net.JMSSink
- 各位大牛,亲们 !帮忙回答上小弟我的有关问题哈,感激不尽
- 多个生产者多个消费者有关问题,帮忙看看吧,感激不尽
- main()函数个数,该如何解决
- JAVA一段程序,求输出结果?初学者,求解,感激不尽!
- Sort排列小疑点 求解 ~哈哈 求求大家帮帮忙 感激不尽~
- 使用了未经检查或不安全的操作,请使用-Xlint:unchecked重新编译解决办法
- "main" java.lang.ArrayIndexOutOfBoundsException: 0
- in thread "main" java.lang.OutOfMemoryError: Java heap space
- Exception in thread "main"不知名的异常!
- Exception in thread "main" java.security.InvalidKeyException:
- 请教哪里有 MDF (Main Distribution Frame) 的接线教程
- 上面的代码会出错,Exception in thread "main" java.lang.Error:
- CMD 运作java XXX.class 出现Could not find the main class