File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Auto Refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Auto Refresh" Watch "Auto Refresh" New topic

Auto Refresh

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
I have a JTextField.When application starts its text is 20.But depending on the database changes it has to refresh to 10 or 50.How to repaint this JTextField.

Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Are you talking about the width of the textfield or the text in the textfield? You shouldn't have to repaint the textfield to change the text, just call setText( String text ). If you need to change the width call setColumns( int columns ). Depending on the layout of the container holding the textfield, you may have to call invalidate() or validate() on the container to get it to resize correctly. Also, these methods should be called from the event thread... if you're calling them from another thread they aren't guaranteed to update automatically.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Auto Refresh
It's not a secret anymore!