Java Bean Problem with JComboBoxes

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Java Bean Problem with JComboBoxes

Postby theschles » Tue Dec 28, 2004 11:07 am

Hi all. Weird thing going on. Discovered that Swing Designer doesn't like the way I'm adding the data to a JComboBox.

I discovered this while trying to add a sub-panel to another panel.

The sub-panel file had a JCombo Box with the following code:

comboBox_1 = new JComboBox();
comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"Cell", "Direct", "Pager"}));
comboBox_1.setLayout(null);
comboBox_1.setSelectedIndex(2);
comboBox_1.setPopupVisible(true);
final GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridy = 0;
gridBagConstraints.gridx = 2;
add(comboBox_1, gridBagConstraints);

The JComboBox works fine via Test/Preview for the sub-panel itself, but when I try to add the Panel via Choose Bean or Choose Panel, either I get a circle-with-diagonal-line "no" symbol or just the regular arrow (but no lattice of dots indicating that it was allowing me to place the sub-panel on the panel itself.

When I manually input the code to add the sub-panel, I got a red box with "Java Bean Problem". Here's the full log entry:

!ENTRY com.swtdesigner 4 4 Dec 28, 2004 10:37:28.171
!MESSAGE Java Bean Problem: dcsgui.AddressPhonePanel
!STACK 0
com.swtdesigner.properties.PropertyException: java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
at com.swtdesigner.model.swing.component.custom.ContainerBeanWithPropertyChildrenInfo.ensureBeanInstance(SourceFile:315)
at com.swtdesigner.model.swing.component.custom.WorkspaceContainerBeanInfo.isBean(SourceFile:185)
at com.swtdesigner.model.swing.component.custom.WorkspaceContainerBeanInfo.fetchDefaultValuesForPropertyDescriptors(SourceFile:175)
at com.swtdesigner.model.swing.JavaBeanInfo.initClassAndBounds(SourceFile:628)
at com.swtdesigner.model.swing.JavaBeanInfo.<init>(SourceFile:172)
at com.swtdesigner.model.swing.component.ComponentBeanInfo.<init>(SourceFile:112)
at com.swtdesigner.model.swing.component.ContainerBeanInfo.<init>(SourceFile:105)
at com.swtdesigner.model.swing.component.custom.ContainerBeanWithPropertyChildrenInfo.<init>(SourceFile:53)
at com.swtdesigner.model.swing.component.custom.WorkspaceContainerBeanInfo.<init>(SourceFile:52)
at com.swtdesigner.model.JavaInfoFactory.create(SourceFile:389)
at com.swtdesigner.model.JavaInfoFactory.create(SourceFile:66)
at com.swtdesigner.model.parser.JavaInfoParser$ParserVisitor.endVisit(SourceFile:1254)
at org.eclipse.jdt.core.dom.ClassInstanceCreation.accept0(ClassInstanceCreation.java:337)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497)
at org.eclipse.jdt.core.dom.VariableDeclarationFragment.accept0(VariableDeclarationFragment.java:200)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
at org.eclipse.jdt.core.dom.VariableDeclarationStatement.accept0(VariableDeclarationStatement.java:267)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
at org.eclipse.jdt.core.dom.Block.accept0(Block.java:135)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497)
at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:502)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at com.swtdesigner.model.parser.JavaInfoParser$ParserVisitor.visit(SourceFile:2436)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:469)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:292)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at com.swtdesigner.model.parser.JavaInfoParser.parse(SourceFile:180)
at com.swtdesigner.gef.DesignerEditor.parseCompilationUnit(SourceFile:724)
at com.swtdesigner.gef.DesignerEditor.handleActivate(SourceFile:658)
at com.swtdesigner.gef.DesignerEditor.handleActivate(SourceFile:626)
at com.swtdesigner.editors.MultiPageEditor.showDesignEditor(SourceFile:288)
at com.swtdesigner.editors.MultiPageEditor$2.widgetSelected(SourceFile:156)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:613)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3053)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1917)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:287)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2772)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2431)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1377)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:254)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:96)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:335)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:273)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:704)
at org.eclipse.core.launcher.Main.main(Main.java:688)
Caused by: java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:1507)
at java.awt.Component.getLocationOnScreen(Component.java:1481)
at javax.swing.JPopupMenu.show(JPopupMenu.java:921)
at javax.swing.plaf.basic.BasicComboPopup.show(BasicComboPopup.java:177)
at javax.swing.plaf.basic.BasicComboBoxUI.setPopupVisible(BasicComboBoxUI.java:927)
at javax.swing.JComboBox.setPopupVisible(JComboBox.java:790)
at dcsgui.AddressPhonePanel.<init>(AddressPhonePanel.java:131)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at com.swtdesigner.model.swing.component.custom.ContainerBeanWithPropertyChildrenInfo$1.run(SourceFile:293)

My DOS console window (from where I started Eclipse) has the following:
Unhandled event loop exception
Reason:
java.lang.NullPointerException

Ideas? How does Swing Designer want me to put in the data for the JComboBox?

- Phil
theschles
 
Posts: 5
Joined: Tue Dec 28, 2004 10:42 am

Re: Java Bean Problem with JComboBoxes

Postby Eric Clayberg » Tue Dec 28, 2004 12:22 pm

theschles wrote:Discovered that Swing Designer doesn't like the way I'm adding the data to a JComboBox

What leads you to the conclusion that there is an issue with how you are addin the data? Does it work, if you comment those lines out?

Does it make any difference, if you try the latest v3.0.1 build?

theschles wrote:The JComboBox works fine via Test/Preview for the sub-panel itself, but when I try to add the Panel via Choose Bean or Choose Panel, either I get a circle-with-diagonal-line "no" symbol or just the regular arrow (but no lattice of dots indicating that it was allowing me to place the sub-panel on the panel itself.

Can you send us a test case? The log entries you provided don't provide enough information.

theschles wrote:When I manually input the code to add the sub-panel, I got a red box with "Java Bean Problem". Here's the full log entry

That appears to be a side effect of some other issue. A test case would allow us to get to the problem quickly.

theschles wrote:How does Swing Designer want me to put in the data for the JComboBox?

Designer doesn't care how you put data in the JComboBox.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: Google [Bot] and 1 guest