【问题标题】:netbeans platform old dialog box how to getApplication()netbeans平台旧对话框如何getApplication()
【发布时间】:2015-05-23 03:10:53
【问题描述】:

我正在将现有应用程序移植到 netbeans 平台,虽然我可能会将一些现有对话框更改为新的通知方法,但有些对话框非常复杂(多个面板等),我宁愿不移植他们,至少现在还没有。我找到了如何获得大型机,

   mainFrame = (JFrame) WindowManager.getDefault().getMainWindow(); 

但我不知道 .getApplication().show() 使用什么

public void configScoreboard() {
    if (!in_race) {
        if (CSBox == null) {
            CSBox = new SBconfig(mainFrame, true);
            CSBox.setLocationRelativeTo(mainFrame);
        }
        Sst01App.getApplication().show(CSBox);
    }
}

我的新 Netbeans 平台应用程序中当然不存在 Sst01App,而且我似乎找不到该应用程序(我想我尝试了所有变量)

【问题讨论】:

    标签: java netbeans-platform


    【解决方案1】:

    经过大量搜索后在 DialogDescriptor 文档下找到它...

    https://ui.netbeans.org/docs/ui_apis/dide/index.html

    我想出了如何创建可以装饰的自定义对话框,.show() 方法仍然是一个问题,但我发现 DialogDisplayer 可以与我创建的对象一起使用。搞定了。

    对话框 sb2Dlg = DialogDisplayer.getDefault().createDialog(sb2);

    无边框和全屏仍然很有趣,但那是另一个话题。

    class MyPanel extends javax.swing.JPanel implements java.awt.event.ActionListener { 
       //buttons, fields, labels, etc.
        ... 
    
       public void requestFocus () { //set focus for one components 
            myField.requestFocus (); 
       }
        ...
       public void actionPerformed(final java.awt.event.ActionEvent ap) { // handling code for buttons
        ...
       }
    }
    MyPanel mp = new MyPanel(); // create new MyPanel 
    Object [] options =  {  new JButton ("Choice 1"), 
                        new JButton ("Choice 2")};
    DialogDescriptor dd = new DialogDescriptor (mp, 
                            "Text in title", 
                             true, 
                             options, 
                             null, 
                             DialogDescriptor.DEFAULT_ALIGN, 
                             null, 
                             mp); //create new modal DialogDescriptor with defined ActionListener 
    mp.requestFocus(); // set focus to component which was specified in MyPanel's         requestFocus() method 
    TopManager.getDefault ().createDialog (dd).show (); //show dialog
    

    【讨论】:

      猜你喜欢
      • 2021-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-17
      • 1970-01-01
      • 2012-05-07
      • 1970-01-01
      相关资源
      最近更新 更多