Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh JTextField (Swing) 1

Status
Not open for further replies.

adrianjohnson

Programmer
May 16, 2002
145
GB
I'm developing software which will retrieve some information from a database, but I'd like to have a text field which will be display "Working" whilst the system is getting the data. The user will activate this part by selecting the table name from a JTree.

So, I've added the text field, set it's text, but when the user selects the table name from the JTree, the text field doesn't update. When the system's finished, and I set the text field to "Waiting" - that works ok.

Some example code (off the top of my head, as I'm not at work):

Code:
// Set the text in the text field.
lblStatus.setText("Waiting");
 
// Do something.
 
// Now get the info from the database.
lblStatus.setText("Working");     // This line not working!
fillTable();    // Call method to get data.
lblStatus.setText("Waiting");     // This line does work.


If I print to the bebug window at those points, it works fine - it's just the text field that isn't updated.

Any ideas?

Thanks,

Adrian Johnson

Windows XP Pro SP2, Java 1.5 update 5, NetBeans 4.1
 
Adrian,

Try forcing the window to repaint...
It's nice to have prompts, but if the fillTable() is always executing at a constant rate (i.e. the table isn't expanding) then you may want to reconsider having the extra prompts.

Code:
[blue]
lblStatus.setText("Working");     // This line not working!
[red]lblStatus.update(lblStatus.getGraphics());[/red]
fillTable();    // Call method to get data.
lblStatus.setText("Waiting");     // This line does work.


[/blue]

Hope that helps,
Ron

typedef map<GiantX,gold, less<std::shortestpathtogold> > AwesomeMap;
 
Brilliant, Ron - that worked a treat.

I hadn't come across it before, as I did a search on this and other forums.

Thanks for your help.

Adrian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top