क्यों इस बटन हैंडलर इसके दूसरे भाग पर अशक्त वापसी करता है?

वोट
0

यह बटन हैंडलर का उद्देश्य एक यादृच्छिक अभिगम फाइल के अंदर एक रिकॉर्ड करने के लिए एक स्थान के लिए एक द्विआधारी पेड़ खोज करने के लिए है। विधि fillInfoField दिए गए डेटा के साथ जीयूआई को भरने के लिए नहीं है। किसी भी प्रकार की सहायता सराहनीय होगी!

    private class HandlerSSN implements ActionListener {
    public void actionPerformed(ActionEvent event) {
        String ssnReqStr = tfReqSSN.getText();
        String num;
        int ssn;

        BalanceOnDemand.Node currNode = null;
        BalanceOnDemand myTree = new BalanceOnDemand();

        if (ssnReqStr.length() == 0) {
            tfMsg.setText(Lookup by Name (partial match allowed));
            tfReqName.requestFocus();
            return;
        } else {
            try {
                raf.seek(0);
                myTree.root = (BalanceOnDemand.Node) ois.readObject();

                num = ssnReqStr.replaceAll([^0-9], );
                ssn = Integer.parseInt(num);
                currNode = myTree.find(ssn);
                System.out.println(currNode);
                if(currNode != null){
                    raf.seek(currNode.loc - REC_LEN);
                    fillInfoFields(readCurrRec());
                }else{
                    System.out.println(Test);
                    tfMsg.setText(SSN \ + tfReqSSN.getText() + \ was not found);
                    return;
                }

            } catch (IOException | ClassNotFoundException e) {
                System.out.println(currNode.id);
                tfMsg.setText(SSN \ + tfReqSSN.getText()
                        + \ was not found);
            }
        }

    }
}

यहाँ मिल विधि यदि आप इसे देखना चाहेंगे है।

public Node find(int key)
{
Node current;
current = root;

while(current!=null && current.id!=key)
  {
    if(key<current.id){
      current = current.left;
    }else{
      current = current.right;
    }
  }
  return current;

}

  class Node implements Serializable

{

private static final long serialVersionUID = 1L;
public int    id;
public int    loc;
public Node   left;
public Node   right;

    public Node(int i,int i2)
    {
      id    = i;
      loc  = i2;
      left  = null;
      right = null;
    }
  }
02/12/2013 को 00:48
का स्रोत उपयोगकर्ता
अन्य भाषाओं में...                            


1 जवाब

वोट
0

मैं अपने दम पर इस हल किया। मैं इनपुट धाराओं में से प्रत्येक के लिए फिर से दृष्टांत की जरूरत है। यहाँ कोड मैं बटन हैंडलर के शीर्ष पर जोड़ा है।

        try
        {
          fis = new FileInputStream("treeObject.dat");
          ois = new ObjectInputStream(fis);
        }
        catch (IOException e)
        {
          e.printStackTrace();
        }
02/12/2013 को 02:42
का स्रोत उपयोगकर्ता

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more