Java 默认关闭操作不更改任何内容

Java 默认关闭操作不更改任何内容,java,jfreechart,Java,Jfreechart,我正在使用JFreeChart库。饼图是应用程序的一小部分,我希望能够调用饼图,关闭它,然后继续使用应用程序。但是,现在它会关闭整个过程,无论我选择哪个WindowConstants.X_ON_CLOSE选项: public PieChart(final List<Window> windows) { super("Kronos - Window Data"); final JFreeChart chart = PieChart.createChart(windows

我正在使用JFreeChart库。饼图是应用程序的一小部分,我希望能够调用饼图,关闭它,然后继续使用应用程序。但是,现在它会关闭整个过程,无论我选择哪个WindowConstants.X_ON_CLOSE选项:

public PieChart(final List<Window> windows) {
    super("Kronos - Window Data");
    final JFreeChart chart = PieChart.createChart(windows);
    SwingUtilities.invokeLater(() -> {
        final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        final int width = (int) screenSize.getWidth();
        final int height = (int) screenSize.getHeight();
        this.setSize(width, height);
        this.setLocationRelativeTo(null);
        super.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        // this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        this.setVisible(true);
    });
    final ChartPanel panel = new ChartPanel(chart);
    this.setContentPane(panel);
}
公共图表(最终列表窗口){
超级(“克罗诺斯-窗口数据”);
最终JFreeChart chart=PieChart.createChart(windows);
SwingUtilities.invokeLater(()->{
最终维度screenSize=Toolkit.getDefaultToolkit().getScreenSize();
final int width=(int)screenSize.getWidth();
final int height=(int)screenSize.getHeight();
此.setSize(宽度、高度);
此.setLocationRelativeTo(空);
super.setDefaultCloseOperation(WindowConstants.DO\u NOTHING\u ON\u CLOSE);
//此.setDefaultCloseOperation(WindowConstants.DO\u NOTHING\u\u ON\u CLOSE);
此.setVisible(true);
});
最终图表面板=新图表面板(图表);
此.setContentPane(面板);
}

找到了一个解决方案,如果我通过
JFrame
而不是
ApplicationFrame
来扩展类,效果很好。还有
WindowConstants。关闭时不执行任何操作
不正确,需要
WindowConstants。关闭时隐藏
在不停止应用程序的情况下隐藏窗口


希望这对其他人有帮助

什么是
PieChart
的超类?您是否有任何指向JFreeChart源代码的链接?请点击此处: