我想在Netbeans Platform
中创建一个简单的模态对话框。
我使用https://github.com/googlesamples/android-media-controller
我做的:
MyForm form = new MyForm();
DialogDescriptor desc = new DialogDescriptor(form, "Hello", true, DialogDescriptor.OK_CANCEL_OPTION,
DialogDescriptor.OK_OPTION, null);
desc.setValid(false);
form.setDialogDescriptor(desc);
DialogDisplayer.getDefault().notify(desc);
MyForm.java
:
static class MyForm extends JPanel implements DocumentListener {
private JTextField field;
private DialogDescriptor desc;
MyForm() {
super(new BorderLayout());
field = new JTextField();
add(new JLabel("Type Something Here"), BorderLayout.NORTH);
add(field, BorderLayout.SOUTH);
}
void setDialogDescriptor(DialogDescriptor desc) {
this.desc = desc;
field.getDocument().addDocumentListener(this);
}
private void doEnablement() {
if (field.getText().isEmpty()) {
desc.setValid(false);
} else {
desc.setValid(true);
}
}
@Override
public void insertUpdate(DocumentEvent e) {
doEnablement();
}
@Override
public void removeUpdate(DocumentEvent e) {
doEnablement();
}
@Override
public void changedUpdate(DocumentEvent e) {
doEnablement();
}
}
运行我的应用程序时,出现错误:
java.lang.ClassNotFoundException: org.openide.NotifyDescriptor
怎么了?如何解决这个问题?我要创建模式窗口,单击按钮即可打开。