aspose file tools*
The moose likes Java in General and the fly likes get a textfield value from a frame to an applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "get a textfield value from a frame to an applet" Watch "get a textfield value from a frame to an applet" New topic
Author

get a textfield value from a frame to an applet

nick stanish
Greenhorn

Joined: Jun 27, 2011
Posts: 8

i have an awt applet that upon clicking a certain area, it opens a frame with textboxes and buttons, however when i use textbox.getText(); the compiler says symbol can't be found
how can i pass a textfield value from the frame?
Wim Vanni
Ranch Hand

Joined: Apr 06, 2011
Posts: 96

Would you mind adding the stack trace?

Cheers,
Wim
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
Welcome to the Ranch

As you have been told, we need to know the details of the error before we can help.
Andrew Thompson
Ranch Hand

Joined: Aug 05, 2010
Posts: 77
    
    5
nick stanish wrote:i have an awt applet that upon clicking a certain area, it opens a frame with textboxes and buttons, however when i use textbox.getText(); the compiler says symbol can't be found
how can i pass a textfield value from the frame?


textbox is an array of TextFields, so textbox[0].getText() should work to get the text of the first.

As an aside.
  • For better help sooner, post an SSCCE.
  • Why on earth are you dealing with an AWT GUI in this millennium?


  • Andrew Thompson
    http://pscode.org/
    nick stanish
    Greenhorn

    Joined: Jun 27, 2011
    Posts: 8

    heres the errors:



    i forgot to include the actionPerformed

    theres more to it of course but i think that should be everything needed, and the first post had the class for the frame i'm using

    I chose awt because i'm more familiar with it than swing and the paint method is easier to use then adding a canvas and painting that component
    Andrew Thompson
    Ranch Hand

    Joined: Aug 05, 2010
    Posts: 77
        
        5
    nick stanish wrote:
    I chose awt because i'm more familiar with it than swing ..


    You may be more familiar with AWT, but the people helping you have mostly forgotten it.

    nick stanish wrote:
    ..theres more to it of course but i think that should be everything needed,..


    I stated what I needed in order to provide further help, and that is not it. Since I can't be of any further help here, ..Good luck with it.
    nick stanish
    Greenhorn

    Joined: Jun 27, 2011
    Posts: 8

    Oh? What am I missing?
    Andrew Thompson
    Ranch Hand

    Joined: Aug 05, 2010
    Posts: 77
        
        5
    nick stanish wrote:Oh? What am I missing?


    I should explain where I'm coming from. The SSCCE document (on which I'm somewhat of an authority) has some very specific requirements for code that calls itself an SSCCE. Those things are the words that make up the abbreviation.

    The 1st word is 'short'. A 'short' example of a compilation problem would not have 5 TextFields and Labels, but just 2. It would not have 5 images, but 2, or in fact, if that was not part of the compilation problem, it would not have any images at all.

    Often in the process of shortening code, bugs can be discovered. That probably does not apply here, but if you trim out all the cruft, it makes the problem shorter to look at. It makes it easier to help.

    The 2nd 'C' stands for 'Correct', which means it should show the same errors for you, as for me. When I went to compile the code, the first message I got was something to do with a missing } at the end of the code. Once that was fixed, the compiler reported a number of errors including the ones you described, but also others to do with the declared interfaces that had not been implemented. I began to comment them out, one by, when I struck yet another error that I could..

    Then I thought, 'stuff this'. By the time I'd have your code anywhere near to producing the compilation errors you reported, it would no longer be the same code. I could just as easily write the code for you. But I have no intention of doing the latter, and since you could not make it easy for me to investigate the code as an SSCCE, I felt my efforts were best spent helping people that can post an SSCCE.

    So, ..I don't know where we can go from here. Can you produce something that is an SSCCE?
    nick stanish
    Greenhorn

    Joined: Jun 27, 2011
    Posts: 8

    Andrew Thompson wrote:Can you produce something that is an SSCCE?

    alright yeah i'll skim it down to as basic as i can make it

    EDIT



    and the compile error
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39791
        
      28
    Apart from the poor design in addActionListener(this), where did you declare textBox?
    nick stanish
    Greenhorn

    Joined: Jun 27, 2011
    Posts: 8

    Campbell Ritchie wrote:Apart from the poor design in addActionListener(this), where did you declare textBox?

    right above the addActionListener
    line 9 TextField textBox = new TextField("");

    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18885
        
        8

    So you're declaring it as a local variable in the init() method?
    nick stanish
    Greenhorn

    Joined: Jun 27, 2011
    Posts: 8

    I believe so, where would be a better place to declare it?
    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18885
        
        8

    Have you reviewed your text or tutorial to find out the ramifications of using a local variable?
    nick stanish
    Greenhorn

    Joined: Jun 27, 2011
    Posts: 8

    No I haven't, I'm not using a text or a tutorial, the first time I wrote this program there was no problem, but now that I'm using a frame in addition to the applet window then I guess it does cause a problem
    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18885
        
        8

    So you're learning Java by asking questions on the forum? Not a good strategy. Here's a link to the Oracle tutorial about variables; as you will see there's a lot more tutorials beyond that. I would strongly suggest working through more tutorials beyond that one.
    nick stanish
    Greenhorn

    Joined: Jun 27, 2011
    Posts: 8

    I'll see what i can do, Thanks for your time and replies
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: get a textfield value from a frame to an applet