Total members 11895 |It is currently Sun Dec 22, 2024 5:31 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





I am developing a simple program to add 2 numbers. It
contains 2 TextFields and 1 Button. When clicked on button, button handler
will add 2 numbers in text fields and puts it in label, add it to the panel.
(All components are panel, and panel is added to the frame.)

The problem is that after adding the label to the panel, I am calling
repaint method on panel, or frame not updating the GUI. But, when I resize
the window with mouse, it updating. If hiding the panel, or frame by using
setVisible and making it visible again updating the GUI.

But, I didn't understand why repaint is not updating the GUI?




Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

It's been a while since I worked in Swing, but this is what I remember:

You can't call repaint () from the code handling your request. This is
the Swing dispatch thread. Instead, use invokeAndWait or invokeLater (I
would advise invokeLater, because it runs the repaint process
asynchronously). See Java's JavaDoc of the SwingUtilities class:
http://java.sun.com/j2se/1.5.0/docs/api ... ities.html

Also check out the Swing tutorial:
http://java.sun.com/docs/books/tutorial ... index.html

_________________
Please recommend my post if you found it helpful


Author:
Proficient
User avatar Posts: 228
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Swing: repaint and setVisible
 What is Swing?!!     -  
 How to create a log in form using javax.swing     -  
 JLabel Class Example Swing Package     -  
 JUnit Testing of GUIs in Swing     -  
 database contents display in table format in swing     -  
 a moving graph sortof widget build using Swing     -  
 old NASA style counter built from Swing components     -  
 an ammeter ( round gauge ) sortof widget built using Swing     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com