• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

get a textfield value from a frame to an applet

 
Greenhorn
Posts: 8
Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 96
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would you mind adding the stack trace?

Cheers,
Wim
 
Marshal
Posts: 80760
487
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

As you have been told, we need to know the details of the error before we can help.
 
Ranch Hand
Posts: 77
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
  •  
    nick stanish
    Greenhorn
    Posts: 8
    Firefox Browser
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 77
    5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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
    Posts: 8
    Firefox Browser
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Oh? What am I missing?
     
    Andrew Thompson
    Ranch Hand
    Posts: 77
    5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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
    Posts: 8
    Firefox Browser
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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
    Marshal
    Posts: 80760
    487
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Apart from the poor design in addActionListener(this), where did you declare textBox?
     
    nick stanish
    Greenhorn
    Posts: 8
    Firefox Browser
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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("");

     
    Sheriff
    Posts: 28411
    102
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    So you're declaring it as a local variable in the init() method?
     
    nick stanish
    Greenhorn
    Posts: 8
    Firefox Browser
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I believe so, where would be a better place to declare it?
     
    Paul Clapham
    Sheriff
    Posts: 28411
    102
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Have you reviewed your text or tutorial to find out the ramifications of using a local variable?
     
    nick stanish
    Greenhorn
    Posts: 8
    Firefox Browser
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Sheriff
    Posts: 28411
    102
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 8
    Firefox Browser
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I'll see what i can do, Thanks for your time and replies
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic