Please help I have problems regarding inputing a value into an array with gui

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kenrocks
    New Member
    • Oct 2008
    • 25

    Please help I have problems regarding inputing a value into an array with gui

    i have 2 classes 1 main with methods and a gui file on the mainfile I have an aDD method.
    [code=java]
    public void aDD(JTextField a, String[] r)
    {
    int x=0;
    while(x<r.lengt h)
    {
    r[x]=a.getText();
    x++;
    }

    }
    [/code]

    and on my gui I have 1 that returns values to the main method
    [code=java]
    if (z.getSource()= = add)
    {
    a3.aDD(f,x);
    f.setText("");

    }
    [/code]

    p.s.f=text area, x is a String array;
    can u help me correct my mistake
    Last edited by Nepomuk; Oct 29 '08, 10:02 AM. Reason: Please use [CODE] tags
  • myusernotyours
    New Member
    • Nov 2007
    • 188

    #2
    Hi,

    Can you make your question a little bit more clear? It's difficult to tell what you are trying to do...

    We are all willing to help, but only if we can understand your problem see this

    Regards,
    Alex.

    Comment

    • kenrocks
      New Member
      • Oct 2008
      • 25

      #3
      my question is...when I add sumthin to my array the result is null can u fix my code plsss...

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by kenrocks
        my question is...when I add sumthin to my array the result is null can u fix my code plsss...
        If you want us to help you you have to be less vague: *what* exactly turns out
        to be null? The array itself? Elements in the array? Something else? Was it
        null before? Where did you notice it was null?

        kind regards,

        Jos

        Comment

        • kenrocks
          New Member
          • Oct 2008
          • 25

          #5
          Originally posted by JosAH
          If you want us to help you you have to be less vague: *what* exactly turns out
          to be null? The array itself? Elements in the array? Something else? Was it
          null before? Where did you notice it was null?

          kind regards,

          Jos
          when a display button is clicked..the return value is null..only the first entry appears and the second remains as null

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by kenrocks
            when a display button is clicked..the return value is null..only the first entry appears and the second remains as null
            Again: *what* return value? And ActionListener doesn't supply you with a return
            value. A first and second entry of *what*? You do have to be as exact as possible.

            kind regards,

            Jos

            Comment

            • kenrocks
              New Member
              • Oct 2008
              • 25

              #7
              the entries ion the array made by this add button..

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by kenrocks
                the entries ion the array made by this add button..
                According to your code you put the same value in every entry (a.getText()). They
                all should be equal. The getText() method can return an empty String "" but not
                null. Or is there some other code that fiddles with the array values?

                kind regards,

                Jos

                Comment

                Working...