如何以编程方式更改“附加”对话框上“端口”字段的默认值?

时间:2011-02-08 20:26:35

标签: netbeans netbeans-plugins

1 个答案:

答案 0 :(得分:0)

要使用此技术,您的模块将需要依赖Debugger Core API,以下内容可能会进入您的Installer(在NetBeans 6.9.1上测试):

    // get the _debugger_ properties
    org.netbeans.api.debugger.Properties props = 
            Properties.getDefault().getProperties("debugger");

    Map<String, Map<String, String>> toSave = new HashMap<String, Map<String, String>>();
    Map<String, String> values = new HashMap<String, String>();
    values.put("port", "123"); // <- this is what you're after
    toSave.put("com.sun.jdi.SocketAttach", values);

    props.setMap("connection_settings", toSave);

作为参考,此设置位于:

  

〜/的.netbeans / 6.9 /配置/服务/ org-netbeans-modules-debugger-Settings.properties

运行此代码后,您将看到以下部分:

  

debugger.connection_settings:#java.util.HashMap
  debugger.connection_settings.0键: “com.sun.jdi.SocketAttach”
  debugger.connection_settings.0-value:#java.util.HashMap
  debugger.connection_settings.0-value.0键: “端口”
  debugger.connection_settings.0-value.0值: “123”
  debugger.connection_settings.0-value.length:1个
  debugger.connection_settings.length:1