Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2007

Tip: Looking for answers? Try searching our database.

JTablle anomaly

Thread view: 
Roedy Green - 31 Dec 2007 04:42 GMT
I have noticed that when my JTable is scrolling, it sometimes displays
the heading line temporarily before replacing it with the proper data
line.  Is this a bug in Swing, or am I doing something wrong?
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 31 Dec 2007 04:48 GMT
On Mon, 31 Dec 2007 04:42:03 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>I have noticed that when my JTable is scrolling, it sometimes displays
>the heading line temporarily before replacing it with the proper data
>line.  Is this a bug in Swing, or am I doing something wrong?

I found a pragmatic solution. After I make my calls that will trigger
gui changes, I use  Thread.yield(); in my computational thread to give
the Swing thread a crack at processing the GUI events.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 31 Dec 2007 12:42 GMT
On Mon, 31 Dec 2007 04:48:48 GMT, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>I found a pragmatic solution. After I make my calls that will trigger
>gui changes, I use  Thread.yield(); in my computational thread to give
>the Swing thread a crack at processing the GUI events.
I still get sporadic anomalies.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Alexander.V.Kasatkin@gmail.com - 31 Dec 2007 18:01 GMT
It's normal situation if a table model is updated by a non-Swing
thread.
IMHO, If you've extends an AbstractTableModel class, you can override
the fireTableChanged method:

<pre>
public class Model extends DefaultTableModel {
   private static final long serialVersionUID =
-5792073620222974655L;
   @Override
   public void fireTableChanged(final TableModelEvent e) {
       if (SwingUtilities.isEventDispatchThread()) {
           super.fireTableChanged(e);
       } else {
           SwingUtilities.invokeLater(new Runnable() {
               @Override
               public void run() {
                   fireTableChanged(e);
               }
           });
       }
   }
}
</pre>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.