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

你们再仔细看看 问题没有那么简单
[code=Java][/code]
  class ButtonAction implements ActionListener{
MyLinkedList list1 = new MyLinkedList();
public void actionPerformed(ActionEvent e){
if(e.getSource() == button1){
String s1 = text1.getText();
String s2 = "02";
list1.add(list1.size(),s1);
list1.add(list1.size(),s2);
int n = list1.getSection(s1);// 这个地方 ,s1改s2 就会出错
text3.setText((String)list1.getElement(n));
}
else if(e.getSource() == button2){
String s2 = text2.getText();//这个地方 还是会报错 为什么在上面就能行呢??
int n = list1.getSection(s2);
text3.setText((String)list1.getElement(n));
}
}
  }

------解决方案--------------------
Java code
class ButtonAction implements ActionListener
{
    MyLinkedList list1 = new MyLinkedList();
    public void actionPerformed(ActionEvent e)
    {
        if(e.getSource() == button1)
        {
            String s1 = text1.getText();
            String s2 = "02";
            List.add(List.size(),s1);
            List.add(list1.size(),s2);
            /*对不起,你这地方是要用String
             * 详情可以参照
             * http://www.eclipselight.org/swt-jface/1022/
             * */
            int n = list1.getSection(s1);// 这个地方 ,s1改s2 就会出错
            text3.setText((String)list1.getElement(n));
        }
        else if(e.getSource() == button2)
        {
            //这个不是很清楚
            String s2 = text2.getText();//这个地方 还是会报错 为什么在上面就能行呢??
            int n = list1.getSection(s2);
            text3.setText((String)list1.getElement(n));
        }
    }
}