aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Text Field not putting data in string and Jlable not repainting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Text Field not putting data in string and Jlable not repainting" Watch "Text Field not putting data in string and Jlable not repainting" New topic
Author

Text Field not putting data in string and Jlable not repainting

James Eman
Ranch Hand

Joined: Mar 10, 2013
Posts: 46
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


Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Mar 10, 2013
Posts: 46
thank i never noticed i did that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Text Field not putting data in string and Jlable not repainting