close关闭指定窗口 matlab_如何从Matlab命令提示符下关闭一个或所有当前打开的Matlab(* .m)文件?...

I found a solution on the web (see below, circa 2009) which does not work on my machine (Windows 7, Matlab R2013a):

Editor = com.mathworks.mlservices.MLEditorServices;

Editor.closeAll;

解决方案

As you noticed, newer versions of Matlab do not return the same type of Java object for the editor.

The main editor service can still be accessed with the same command as before:

edtSvc = com.mathworks.mlservices.MLEditorServices ; %// get the main editor service ;

But this only return the handle of the service, not individual editor.

As answered by Daniel, you can close the full service from there, which will close all the editors at once. You can use one of the 2 methods available:

edtSvc.getEditorApplication.close ; %// Close all editor windows. Prompt to save if necessary.

edtSvc.getEditorApplication.closeNoPrompt ; %//

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Java中,要实现点击按钮后关闭当前窗口,同时打开一个窗口,可以通过以下步骤实现: 1. 创建一个JFrame窗口,设置窗口的大小和关闭方式。 2. 创建一个JPanel面板,添加到窗口中,并设置布局管理器。 3. 创建一个JButton按钮,添加到面板中,并添加ActionListener监听器。 4. 在监听器中,使用setVisible()方法关闭当前窗口,再创建一个新的JFrame窗口并设置其可见。 下面是一段示例代码,演示如何实现点击按钮后关闭当前窗口,同时打开一个窗口: ```java import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class OpenNewWindowDemo { public static void main(String[] args) { JFrame frame = new JFrame("Open New Window Demo"); frame.setSize(400, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JButton openButton = new JButton("Open New Window"); openButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.setVisible(false); // 隐藏当前窗口 JFrame newFrame = new JFrame("New Window"); newFrame.setSize(400, 300); newFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); newFrame.setVisible(true); // 显示新窗口 } }); panel.add(openButton, BorderLayout.CENTER); frame.add(panel); frame.setVisible(true); } } ``` 在上面的示例中,我们创建了一个窗口,并添加了一个按钮。在按钮的ActionListener中,我们使用setVisible()方法将当前窗口隐藏,并创建一个新的JFrame窗口并设置其可见。运行程序,点击按钮,当前窗口将被关闭,并打开一个新的窗口
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值