javaSwing 关闭窗口,弹出消息框,无论我点击是,否 都关闭窗口,见代码!
//关闭窗口事件privatevoidWindowClosingForm(java.awt.event.WindowEventevt){intflag=JOptionPa...
//关闭窗口事件 private void WindowClosingForm(java.awt.event.WindowEvent evt) { int flag = JOptionPane.showConfirmDialog(null, "确定要退出吗", "退出", JOptionPane.OK_CANCEL_OPTION); if (flag == JOptionPane.OK_OPTION) { System.exit(0); } }
/*
即使我不加 IF语句,return; 窗口照样关闭
*/
我也去掉过System.exit(0); 这条语句也会关闭窗口 展开
/*
即使我不加 IF语句,return; 窗口照样关闭
*/
我也去掉过System.exit(0); 这条语句也会关闭窗口 展开
2个回答
展开全部
构造函数中加一句setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-04-29
展开全部
consume
protected voidconsume()
Consumes this event, if this event can be consumed. Only low-level,
system events can be consumed
isConsumedprotected booleanisConsumed()Returns whether this event has been consumed.
protected voidconsume()
Consumes this event, if this event can be consumed. Only low-level,
system events can be consumed
isConsumedprotected booleanisConsumed()Returns whether this event has been consumed.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询