• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

text field in new window

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

I'd like to add text field and read its value. I have posted this question on the other forum, but it was not in English language and finally the problem has not been solved.

The code which I have:



Previously I was trying to use



The application launches (in previous and actual version of code) but does not show any text box. How may I correct the code?

Regards!
 
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change the class to extend JFrame and not Frame and try to add the text field's to its content pane like below -


You shall also change TextField to JTextField.
 
Johny Wyenski
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear John,

thank you for your answer! As I wrote in my first post, I have already tried it. So I change again to the previous version of code:



and I can see the same what previously:

cannot find symbol
symbol: method getContentPane()
location: class NameOfMyClass



The NetBeans IDE can create this symbol for me, but it still needs to be implemented (and I think I don't need to implement it but rather to change something in the code quoted above):



Regards!
 
John Jai
Rancher
Posts: 1776
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm... did you try changing Frame to JFrame? I didn't see that modification in the code you posted.

public class NameOfMyClass extends JFrame
 
Johny Wyenski
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!

OK, solved. I needed to add:



but also



Regards!
 
It was the best of times. It was the worst of times. It was a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic