Generic Panel/Dialog with Actions will not render GUI [message #899699] |
Wed, 01 August 2012 18:55  |
Eclipse User |
|
|
|
I have a generic class that extends JPanel. As soon as I introduce an Action the class will no longer generate the UI. I get a null pointer exception.
If I make the class non-generic, or I don't create an instance of the Action in the constructor then it will generate the UI successfully.
I have been able to reproduce this on multiple classes (JPanel and JDialog), attached in a report from a simple example that does not need to be generic, but is a simple example that removes other dependencies and possible other causes
public class OKCancelDialog<T> extends JDialog {
protected JPanel buttonPanel;
protected JButton btnOk;
protected JFrame frame;
public OKCancelDialog(JFrame frame,boolean modal) {
super(frame,modal);
buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.RIGHT);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
btnOk = new JButton("OK");
btnOk.setAction(new OKAction());
buttonPanel.add(btnOk);
}
private class OKAction extends AbstractAction {
public OKAction() {
putValue(NAME, "ok");
}
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
}
}
java.lang.NullPointerException
at org.eclipse.wb.internal.swing.model.bean.ActionInfo.refreshIconImage(ActionInfo.java:118)
at org.eclipse.wb.internal.swing.model.bean.ActionInfo.access$1(ActionInfo.java:115)
at org.eclipse.wb.internal.swing.model.bean.ActionInfo$3.refreshed(ActionInfo.java:83)
at sun.reflect.GeneratedMethodAccessor111.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
....
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03493 seconds