我正在使用此代码
private void botaoGrafADMouseClicked(java.awt.event.MouseEvent evt) {
try {
boolean[] b=new boolean[8];
if (Caixa9.isSelected()) b[0]=true; else b[0]=false;
if (Caixa11.isSelected()) b[1]=true; else b[1]=false;
if (Caixa10.isSelected()) b[2]=true; else b[2]=false;
if (Caixa12.isSelected()) b[3]=true; else b[3]=false;
b[4]=false;b[5]=false;b[6]=false;b[7]=false;
final LineChartDemo1 demo = new LineChartDemo1("Leitura A/D",b,"outad.txt",4);
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
} catch (IOException ex) {
Logger.getLogger(Comunicacao.class.getName()).log(Level.SEVERE, null, ex);
}
}
调用图形接口(interface)。但是,当我这样做时,每次调用图形时,它都会在新窗口上生成,如果我关闭这些窗口,整个程序就会关闭。 我想知道我做错了什么。我怎样才能避免这种情况(我会发布一个打印屏幕,但是,作为新用户,我不能,它在 /image/4JLxQ.png 我认为
编辑:图像
最佳答案
JFrame 有一个默认的关闭操作(即使用窗口管理器关闭窗口时会发生什么)EXIT_ON_CLOSE。使用JFrame.setDefaultCloseOperation设置不同的值。
关于java - 如何在java中创建图形窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9534696/