5

I have integrated this Jfreechart Bar Demo with my swing application. I have put the following code in the action performed method of a button, this code was previously in the main method of the Bar Demo class.

final BarChart3DDemo3 demo = new BarChart3DDemo3("3D Bar Chart Demo 3");
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);

This is generating the Bar Chart. But on closing the Bar chart Window. My Whole application is getting closed.

I have tried to insert demo.getDefaultCloseOperation(ApplicationFrame.DISPOSE_ON_CLOSE); but its not working. Although not giving any error.

I have also tried to insert this in the BarChart3DDemo3 constructor but its giving error getDefaultCloseOperation() method does not take int argument.

I have no clue what to do next? Please help. Thanks.

mKorbel
  • 109,107
  • 18
  • 130
  • 305
JavaBits
  • 1,959
  • 11
  • 34
  • 38

2 Answers2

12

Note that ApplicationFrame "listens for window closing events, and responds by shutting down the JVM." It's intended for demo applications. Instead, put your ChartPanel in a JFrame, as shown here.

Community
  • 1
  • 1
trashgod
  • 200,320
  • 28
  • 229
  • 974
-1

Instead of

public class LineChart_AWT extends ApplicationFrame ,

public class LineChart_AWT extends JFrame is working fine.

Community
  • 1
  • 1