原码是:
package studentms;
import com.borland.jbcl.layout.*;
import java.awt.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.table.*;
import java.util.*;
import java.awt.event.*;
import java.io.InputStream;
public class gradeShow extends JFrame {
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JButton jBExit = new JButton();
JScrollPane jScrollPane1 = new JScrollPane();
Vector tempvector=new Vector(1,1);
DefaultTableModel model =new DefaultTableModel();
JTable jTabGradeInfo = new JTable(model);
client is=new client() ;
public gradeShow() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jLabel1.setFont(new java.awt.Font("Dialog", 0, 14));
jLabel1.setText("以下为查询结果:");
xYLayout1.setWidth(409);
xYLayout1.setHeight(337);
// model中加入列名
model.addColumn("学号") ;
model.addColumn("总分") ;
model.addColumn("语文") ;
model.addColumn("数学") ;
model.addColumn("英语") ;
model.addColumn("综合") ;
this.getContentPane().setLayout(xYLayout1);
jTabGradeInfo.setFont(new java.awt.Font("Dialog", 0, 12));
jScrollPane1.setFont(new java.awt.Font("Dialog", 0, 12));
jBExit.setFont(new java.awt.Font("Dialog", 0, 12));
jBExit.setMargin(new Insets(2, 2, 2, 2));
jBExit.setText("退 出");
jBExit.addActionListener(new gradeShow_jBExit_actionAdapter(this));
this.getContentPane().add(jScrollPane1, new XYConstraints(27, 51, 356, 241));
this.getContentPane().add(jBExit, new XYConstraints(330, 303, 53, 24));
this.getContentPane().add(jLabel1, new XYConstraints(28, 26, 133, 19));
jScrollPane1.getViewport().add(jTabGradeInfo, null);
}
//调用此函数就可以生成一个窗体,供排序时用,每次排序时只需
//调用一次即可,避免了代码的重复
void createFrame(gradeShow shareFrame){
shareFrame.setLocation( 190,130);
shareFrame.pack();
shareFrame.show();
shareFrame.jLabel1 .setText("以下为排序结果:");
jLabel1.setFont(new java.awt.Font("Dialog", 0, 14));
}
//供查询调用的函数,显示结果列表
boolean resultShow(String sql,int nun){
byte[] io=new byte[1000];
io=is.client(sql);
if(new String(io,0,4)==null){
//判断连接是否成功
JOptionPane.showMessageDialog(null, "连接失败!");
this.dispose();
return false;}
if(new String(io,0,4).equals("null")){ //判断记录是否存在
JOptionPane.showMessageDialog(null, "无满足条件的记录!");
this.dispose();
return false;}
int line=is.setlen();
int x[]=new int[100];
int s=1;
x[0]=0;
for(int i=0;i<line;i++)
{
if(new String(io,i,1).equals(">")){x[s]=i;
s++;System.out.print("i="+i);
System.out.println("x[s]="+x[s]);
}
}
System.out.println("x[s]="+x[s]);
System.out.println("s="+s);
while (s>0) {
tempvector = new Vector(1, 1);
tempvector.add(new String(io,x[s-1],x[s]-x[--s]));
System.out.println("s="+s);
tempvector.add(new String(io,x[s-1],x[s]-x[--s]));
System.out.println("s="+s);
tempvector.add(new String(io,x[s-1],x[s]-x[--s]));
System.out.println("s="+s);
tempvector.add(new String(io,x[s-1],x[s]-x[--s]));
System.out.println("s="+s);
tempvector.add(new String(io,x[s-1],x[s]-x[--s]));
System.out.println("s="+s);
tempvector.add(new String(io,x[s-1],x[s]-x[--s]));
System.out.print(s);
model.addRow(tempvector);
}
return true;
}
void jBExit_actionPerformed(ActionEvent e) {
this.dispose() ;
}
}
class gradeShow_jBExit_actionAdapter implements java.awt.event.ActionListener {
gradeShow adaptee;
gradeShow_jBExit_actionAdapter(gradeShow adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jBExit_actionPerformed(e);
}
}
其中执行了"io=is.client(sql);"后io的字符行是12>273>65>87>57>64;
运行的结果是:
i=2x[s]=0
i=6x[s]=0
i=9x[s]=0
i=12x[s]=0
i=15x[s]=0
x[s]=0
i的值没有正常的赋值给x[s];
主要语句段是:
for(int i=0;i<line;i++)
{
if(new String(io,i,1).equals(">")){x[s]=i;
s++;System.out.print("i="+i);
System.out.println("x[s]="+x[s]);
}
还请那位高手帮我解答一下,谢谢
----------------解决方案--------------------------------------------------------
你Client的代码都没有帖出来
----------------解决方案--------------------------------------------------------