日期:2014-05-20  浏览次数:20940 次

求助了~这个程序运行的时候说 main里的数组越界~请高手帮忙看看,还有必须用-Xlint才能编译,为啥呢?小弟感激不尽
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.