Help with DialogWrapper

Hi,

when i invoke the Dialogwrapper subclass implemented as below, i just see the ok and cancel buttons and do not see my panel. can some one point what i am missing?

//Dialogwrapper

public class NewClassDialog extends DialogWrapper {
    private NewClassPanel panel;

    @Override
    protected void doOKAction() {
        super.doOKAction();    //To change body of overridden methods use File | Settings | File Templates.
    }

    protected NewClassDialog(boolean canBeParent) {
        super(canBeParent);
        init();
        panel = new NewClassPanel();
    }

    @Override
    protected JComponent createCenterPanel() {
       return panel;
    }


}

I invoke insider the button handler in the following function

private void configureAddClass() {
        addClassButton = new JButton();
        addClassButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              NewClassDialog dialog = new NewClassDialog(true);
              dialog.getPeer().setTitle("Add New Class");
                dialog.createCenterPanel();
              dialog.show();
            }
        });

NewClassPanel is a class extending Jpanel and have buttons and textfield.

Thanks.

2 comments
Comment actions Permalink

Hello Deeps,

You need to move the init() call to the end of the constructor.

when i invoke the Dialogwrapper subclass implemented as below, i just
see the ok and cancel buttons and do not see my panel. can some one
point what i am missing?

//Dialogwrapper

public class NewClassDialog extends DialogWrapper {
private NewClassPanel panel;
@Override
protected void doOKAction() {
super.doOKAction();    //To change body of overridden methods
use File | Settings | File Templates.
}
protected NewClassDialog(boolean canBeParent) {
super(canBeParent);
init();
panel = new NewClassPanel();
}
@Override
protected JComponent createCenterPanel() {
return panel;
}
}

I invoke insider the button handler in the following function

private void configureAddClass() {
addClassButton = new JButton();
addClassButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
NewClassDialog dialog = new NewClassDialog(true);
dialog.getPeer().setTitle("Add New Class");
dialog.createCenterPanel();
dialog.show();
}
});
NewClassPanel is a class extending Jpanel and have buttons and
textfield.

Thanks.

---
Original message URL:
http://devnet.jetbrains.net/message/5304294#5304294


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks a ton Dmitry. you are the saviour !

0

Please sign in to leave a comment.