1

I have a program were I want to have a plotter that updates in realtime. I am going to use jchart2d, but how do I integrate that into my swing gui? I have a internalframe but it does not seem to take my chart. That is the jInternalFrame has no contents.

private void initObjects(){
    trace =new Trace2DLtd(200);
    trace.setColor(Color.Blue);
    Chart2D.cjart = new Chart2D();
    chart.addTrace(trace);
    jInternalFrame1.getContentPane().add(chart);
   }

later on when I update

 public void update()
{ trace.addPoint(elapsedtime,activity)}

What am i doing wrong

Mohsin
  • 852
  • 8
  • 28
DavyGravy
  • 311
  • 1
  • 4
  • 14
  • are you using any layout for the jInternalframe1 ? Show the code how you have declared the jInterframe1. – Mohsin Nov 06 '12 at 13:39

1 Answers1

3

InternalPie is a complete example that adds a ChartPanel to a JInternalFrame.

Addendum: Like JFrame, JInternalFrame defaults to BorderLayout and add() forwards to the content pane's BorderLayout.CENTER; pack() should precede setVisible().

ChartPanel cp = new ChartPanel(chart);
JInternalFrame jif = new JInternalFrame("Chart", ...);
jif.add(cp);
jif.pack();
jif.setVisible(true);

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045