开发者

Closing jfreechart swing window closing down the whole application

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.


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.


Instead of

public class LineChart_AWT extends ApplicationFrame ,

public class LineChart_AWT extends JFrame is working fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜