Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java JTable Screen Blink Problem  RSS feed

 
Kumar SKG
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I am facing Screen blink issue while using the JTable.

JTable is updated in real Time, It uses custom table model.

To update the JTable, I update the Table Model and then call the UpdateUI() and repaint(). These update process is running in non-AWTevent-dispatch thread. So, During the real Time Update of the Table, When we do some rough handling work on the Table( for example, press the Enter Key on the Table for 1-2 minutes, move the Scroll Bar up and down fastly etc), It throws the following exception and the Table starts blinking.

java.lang.NullPointerException
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1141)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
...
...
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

The blinking also moves to Other Components such as JTree which is doing real time update in another screen of the Same Application.

How to resolve this Screen Blinking Phenemenon ? Some suggested to use SwingUtilities.invokeLater() for UpdateUI(). But, I am concerned about the performance, using it in real time update as it may create many threads, it may cause other performance issues. Is other any other better solution ?

Looking forward to your comments !

Thanks !
 
Nick Meverden
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe unrelated but on *nix systems Toolkit.sync() is needed in some cases to fix repaint issues when lots of repainting or drawing is being done.

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Toolkit.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!