请问在swt中怎样阻止窗体上的关闭按钮,重写他的动作。

jilili 2004-08-26 10:05:25
请问在swt中怎样阻止窗体上的关闭按钮,重写他
谢谢!!!
...全文
324 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ming2008 2005-03-24
  • 打赏
  • 举报
回复
设置窗口关闭属性为:

this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

然后截取关闭事件:

this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{

}});
congbailing_914 2005-03-03
  • 打赏
  • 举报
回复
你可以用普通的Frame,因为JFrame窗口一建立的时候它的“x”就已经有关闭的功能了!
普通的Frame建立后“x”是需要自己添加功能的!
ghostvalley 2005-02-23
  • 打赏
  • 举报
回复 1
shell.addShellListener(new ShellAdapter(){
public void shellClosed(ShellEvent e){
e.doit = false;
}
});
since2006 2005-02-07
  • 打赏
  • 举报
回复
给shell添加.addDisposeListener() {}

把 .doit = false
试试。。
drinkant 2004-08-26
  • 打赏
  • 举报
回复

用邦迪把那个关闭按钮贴上即可

jilili 2004-08-26
  • 打赏
  • 举报
回复
我使用 SWT 这个函数在那?
射天狼 2004-08-26
  • 打赏
  • 举报
回复
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); //防止点击窗口的关闭按钮退出

//退出按钮事件
btnExit.addActionListener(new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
funExit ();
}
});


//***************************************************
//名称:funExit
//功能:退出确定函数
//输入:
//输出:
//返回:
//***************************************************
private void funExit ()
{
try
{
if (JOptionPane.showConfirmDialog (this, "确定要退出系统吗?", "信息", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
{
System.exit (0);
}
}
catch (Exception e)
{
System.exit (0);
System.out.println (e.getMessage ());
}
}

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧