if i try to set a JPopoupMenu to a Panel with GridBagLayout the SwingDesigner react with a "WindowBuilder internal error".
- Code: Select all
java.lang.NullPointerException
at com.instantiations.designer.swing.model.layout.gbl.GridBagConstraintsInfo.getCurrentObjectFields(GridBagConstraintsInfo.java:55)
at com.instantiations.designer.swing.model.layout.gbl.AbstractGridBagConstraintsInfo.refresh_fetch(AbstractGridBagConstraintsInfo.java:122)
at com.instantiations.designer.core.model.ObjectInfo.refresh_fetch(ObjectInfo.java:566)
at com.instantiations.designer.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:139)
at com.instantiations.designer.swing.model.component.ContainerInfo.refresh_fetch(ContainerInfo.java:227)
at com.instantiations.designer.swing.model.component.menu.JPopupMenu_Info.refresh_fetch(JPopupMenu_Info.java:96)
at com.instantiations.designer.core.model.ObjectInfo.refresh_fetch(ObjectInfo.java:566)
at com.instantiations.designer.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:139)
at com.instantiations.designer.swing.model.component.ContainerInfo.refresh_fetch(ContainerInfo.java:227)
at com.instantiations.designer.core.model.ObjectInfo.refresh_fetch(ObjectInfo.java:566)
at com.instantiations.designer.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:139)
at com.instantiations.designer.swing.model.component.ContainerInfo.refresh_fetch(ContainerInfo.java:227)
at com.instantiations.designer.core.model.ObjectInfo$5$1.run(ObjectInfo.java:439)
at com.instantiations.designer.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:122)
at com.instantiations.designer.core.model.ObjectInfo$5.run(ObjectInfo.java:436)
at com.instantiations.designer.swing.utils.SwingUtils$1.run(SwingUtils.java:60)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
The problem is that the generated source looks like
- Code: Select all
GridBagConstraints gbc_extPopupMenu = new GridBagConstraints();
...
contentPane.add(getExtPopupMenu(), gbc_extPopupMenu);
But it should be something like this
- Code: Select all
addPopup(getPanel(), getExtPopupMenu());
protected ExtPopupMenu getExtPopupMenu() {
if (extPopupMenu == null) {
extPopupMenu = new ExtPopupMenu();
}
return extPopupMenu;
}
private static void addPopup(Component component, final JPopupMenu popup) {
component.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
showMenu(e);
}
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
showMenu(e);
}
}
private void showMenu(MouseEvent e) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
});
}
or maybe not allow to put a PopupMenu on a Container.
regards,
michael