0

I'm making a Java Swing application, which loads data from a MySQL database and puts it in a Gantt Chart (I'm using the swiftgantt 4.0 library for this).

I have a start window from where you can instantiate multiple JFrame objects which contains a Gantt chart, you can select from the start window what data you want to retrieve from the database.

The program opens the frames with the charts correctly generated, but the problem is, that at certain action e.g.:resizing the window, or scrolling, or clicking on the chart, the content of the last frame appears in the other frame.

If I use the refreshing function of the Gantt chart, the content switches back, to the original content, but I think it's not a good solution to put the refreshing function to all events where this anomalies happen.

Does anyone have a clue what's happening here? I'm thinking of some event handling of the frames, might mix up the charts of the windows, but I'm not sure what causes this.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • 4
    1) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) 2) For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal Complete and Verifiable Example). – Andrew Thompson Jun 11 '14 at 08:55
  • Could you provide some sudo code / code for us to better understand your problem? – e.doroskevic Jun 11 '14 at 09:27
  • I have a class: ChartFrame which extends JFrame. The main content is a reference to a Chart instance which is an extended version of the GanttChart class provided by the SwiftGantt library I use. I jave a StartFrame which extends from JFrame. This has a start button, that if you press, it instantiates a ChartFrame object and I save the reference of it in a List chartFrameReferences; and I always set the last one to be visible: chartFrameReferences.add(new ChartAblak(projectName,projectID,scale,schedType)); chartFrameReferencesget(chartFrameReferences.size()-1).setVisible(true); – akmeddie Jun 11 '14 at 11:40
  • so if you click the Start button each time, a new JFrame appears which contains a GanttChart, that is loaded with data from a database in the constructor of the Chart class. The purpose of multiple windows is to compare different scheduling strategies applied to projects. You can set parameters of the schedule int the StartWindow. Now if I have more than 1 ChartFrames and if I do some stuff(resize one of the window, click on the chart etc.) the content of the last frame appears in another frame. I don't know what causes this, that's the question. – akmeddie Jun 11 '14 at 11:40
  • Also an interesting thing, that if this phenomenon occurs, the proper Chart reference is still there in the ChartFrame class, because i tried to write some windowresizelisteners etc. to call a function of the Chart which refreshes the data of the chart, and proper Chart appears again. I was thinking, that there might be some thing going on int background in the JFrame class that enables different windows to see the content. I hope this helps a bit, to help. – akmeddie Jun 11 '14 at 11:40
  • One more thing: I tried to have one Jframe, which contained a TabbedPane and the tabs contained the charts, but unfortunately, the happened here also... – akmeddie Jun 11 '14 at 11:52
  • 1
    *"One more thing:"* Who are you replying to? Add @E.Doroskevic (or whoever, the `@` is important), to *notify* the person of a new comment. I have to guess you were not replying to me, since you completely ignored my advice to post an MCVE. – Andrew Thompson Jun 13 '14 at 03:19

0 Answers0