• 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 not putting data in string and Jlable not repainting

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok so at my school we use this website for practice quizes but half the time its down and half the time there a bug or something that crashed and you have to restart. so im trying to write a group of programs that we be the quizes but i have run into a few problems the first is the Jlabel dose not update and second is when you click the button it dose not put the data entered into the textfield into the string. i have just been learning GUIs for a week at most but have been taking classes for Java its self for a littel less then a year so dont hate on my code please its not perfect.

Heres the code


 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a) in your class declarations you have this
JTextField tf1 = new JTextField(2);

b) in public void GUI_1() you have this
JTextField tf1=new JTextField();
...
pane.add(tf1);

the tf1 in (b) is the one you see on the screen
the tf1 in (a) is the one accessed by the listener (it is not on the screen, so nothing is entered into it)

either remove JTextField tf1=new JTextField() from (b), or change it to
tf1=new JTextField();

see how you go with that change
 
James Eman
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank i never noticed i did that.
 
reply
    Bookmark Topic Watch Topic
  • New Topic