Hello,
I started to optimize freerails. First I only wanted to make the game logic much faster, but now I’m lost in swing
Using the OpenGL rendering pipeline in 1.6.0_03 or the DirectX rendering pipeline in 1.6.0_10-b08 (from the Java SE 6 Update N site) I have the following problem:
The game works and the fps is around 100, everything works ok, as long as I don’t open an internal dialog (of type JInternalFrame), then the whole swing gui responds very slow. The weird thing is that the game still runs at 100fps (but now with maximum cpu load), but e.g. mouse events have a delay of 2-4 seconds.
One thing is that the number of events in the SynchronizedEventQueue rises (from 1-2 events/second to 700events/s). Almost all of this came from revalidate() (see stack trace below). The problem occurs with JLabel.setText(). If I generate all possible JLabels at start (at this point the text can have only some values) and instead return them in getListCellRendererComponent(), the GUI does again responds to mouse actions.
If I don’t use the OpenGL rendering pipeline, I still have the many Events, but no GUI response problem.
AND I don’t have the problem in 6uN build 08 with the OpenGL rendering pipeline!
Had anyone similiar problems?
bye
Roland
Stacktrace:
at jfreerails.client.top.SynchronizedEventQueue.postEvent(SynchronizedEventQueue.java:49)
at java.awt.EventQueue.invokeLater(EventQueue.java:954)
at javax.swing.SwingUtilities.invokeLater(SwingUtilities.java:1264)
at javax.swing.JComponent.revalidate(JComponent.java:4796)
at javax.swing.JLabel.setText(JLabel.java:325)
at jfreerails.client.view.TrainSummaryJPanel.getListCellRendererComponent(TrainSummaryJPanel.java:99)
at javax.swing.plaf.basic.BasicListUI.paintCell(BasicListUI.java:195)
at javax.swing.plaf.basic.BasicListUI.paintImpl(BasicListUI.java:304)
at javax.swing.plaf.basic.BasicListUI.paint(BasicListUI.java:227)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:143)
at javax.swing.JComponent.paintComponent(JComponent.java:763)
at javax.swing.JComponent.paint(JComponent.java:1027)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JViewport.paint(JViewport.java:747)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at jfreerails.client.view.TrainListJPanel.paint(TrainListJPanel.java:300)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5129)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1382)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1313)
at javax.swing.RepaintManager.paint(RepaintManager.java:1128)
at javax.swing.JComponent.paint(JComponent.java:1013)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at java.awt.Component.lightweightPaint(Component.java:2896)
at java.awt.Container.lightweightPaint(Container.java:1878)
at java.awt.GraphicsCallback$PeerPaintCallback.run(GraphicsCallback.java:67)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at java.awt.Component.paintAll(Component.java:2881)
at java.awt.GraphicsCallback$PaintAllCallback.run(GraphicsCallback.java:43)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:90)
at java.awt.Container.paintComponents(Container.java:1865)
at jfreerails.client.top.GameLoop.run(GameLoop.java:106)
at jfreerails.launcher.Launcher$1.run(Launcher.java:259)
at java.lang.Thread.run(Thread.java:619)