Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 9:54 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: Swing: repaint and setVisible
PostPosted: Thu Oct 23, 2008 12:39 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

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?


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Swing: repaint and setVisible
PostPosted: Thu Oct 23, 2008 12:40 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:53 pm
Posts: 229
Has thanked: 0 time
Have thanks: 0 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


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 database contents display in table format in swing
 JAVA SWING with financial background - NJ USA
 an ammeter ( round gauge ) sortof widget built using Swing
 Java Swing 2nd Edition
 JUnit Testing of GUIs in Swing
 What is Swing?!!
 a moving graph sortof widget build using Swing
 old NASA style counter built from Swing components
 How to create a log in form using javax.swing

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 5 guests



Jump to:  
Previous Question | Next Question  cron




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team