Images not displaying in Buttons in Design mode

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

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

Images not displaying in Buttons in Design mode

Postby Alex Senkevitch » Mon Jan 21, 2008 4:31 pm

I have a bit of a problem, and didn't see mention of it here. I'm using SWT Designer 6.5.1 and have noticed that I am unable to use PNG images (or any that I can tell) as images in standard Button widgets (ala setImage() ). I can navigate to the image file using the ellipsis button on the "Image" line in the Property view, and if I click on "Source" mode I can see that SWT Designer has correctly generated the setImage() code with the correct image path+filename.

However, it will not render in Design or Preview and after Refreshing/reloading the source file, the setImage content (path) does not appear in the "Image" property for the Button (looks like the setImage line is not being parsed by the Property view???)...any thoughts? I don't even know where to begin to debug this one.

Thanks.

-Alex
Alex Senkevitch
 
Posts: 4
Joined: Mon Jan 21, 2008 4:22 pm

Re: Images not displaying in Buttons in Design mode

Postby Eric Clayberg » Wed Jan 23, 2008 12:23 pm

I don't know. I tried it with several PNG images and it seemed to work fine...

Image

Does this happen with specific PNG files or all of them?

Does it matter where the image is located?

Does it happen with GIFs or JPGs?
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

Re: Images not displaying in Buttons in Design mode

Postby Alex Senkevitch » Wed Jan 23, 2008 2:49 pm

Eric,

Thanks for the response. Here are answers to your questions in the order you asked:

No, any valid file.

Apparently not. While I haven't tried dozens of permutations I did try some, and I have been using the location/configuration that I have used now (successfully) for months (albeit in versions prior to 6.5.1). I'm locating it "relative to source" and in its own subdirectory (I have tried "icons", as well as nested in a package dir, i.e., "org.xyz.tools.tool.graphics"). All to no avail.

Yes. Any (that I have seen...or not seen as the case might be) graphic I have tried fails to work.


Again, I would _stress_ that, much like in your screen capture the "Image" property is populated with the name of the graphic file, in mine, it _does not_, regardless of type or location. However, in the source view, this is what is appending into the code block:

Code: Select all
      this.btnAddEncoding = new Button(grpEncodingValues, SWT.NONE);
      this.btnAddEncoding.setImage(SWTResourceManager.getImage(MainWindow.class, "/icons/icon1.jpg"));
      this.btnAddEncoding.setImage(SWTResourceManager.getImage(MainWindow.class, "/icons/icon1.jpg"));
      this.btnAddEncoding.setImage(SWTResourceManager.getImage(MainWindow.class, "/icons/add.png"));
      btnAddEncoding.setBounds(329, 50, 115, 110);


For each attempt (even for the same graphic file, thus the duplicate entries), it is appending a "setImage" method, but (obviously) it is not rendering. To me, it looks like something is wrong with the code parser--transitioning from code to Property....

The only other thing I can tell you is that the "buttons" in question are: contained within a Group, within a Composite, within a TabItem, within a JFace AppWindow.

Sooo, now I'm back to my previous statement...I have NO clue where to look on this one.

Thanks.

-A
Alex Senkevitch
 
Posts: 4
Joined: Mon Jan 21, 2008 4:22 pm

Re: Images not displaying in Buttons in Design mode

Postby Eric Clayberg » Thu Jan 24, 2008 1:25 pm

Do any exceptions appear in your Eclipse ".log" file?

If it isn't working for any image in any location, there is something seriously broken in your eclipse environment. Whether it is Eclipse or Designer or something else interferring, I don't know.

As an experiment, I would suggest installing the latest Designer build into a clean Eclipse 3.3.1.1 environment.
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

Re: Images not displaying in Buttons in Design mode

Postby Alex Senkevitch » Thu Jan 24, 2008 5:28 pm

Update: Hmm, well, I was drafting the following response (with log output showing a Designer error), and I went back to the Design view to try and get it to trigger again, but now, THE BUTTONS ARE DRAWING?!?! I'm confused. The only other thing that was (even remotely) going on was that I am using JDK 6, but had it set--until this morning--to source compatibility 5.0. No it is native 6.0 mode. Maybe that was it? Oh well, it appears to be fixed now (crossing fingers).

-- Original Post --
OK, well, looked through the various log files, the good news: looks like I found a likely suspect in the error logs; the bad news: it is within design (excerpt follows).

Code: Select all
!ENTRY com.swtdesigner 4 4 2008-01-23 17:41:02.343
!MESSAGE Designer internal error [6.5.1.20080117125226]: btins.ehcoe.polycoder.ui.MainWindow
!STACK 0
java.lang.ClassNotFoundException: xxx.yyy.zzz.ui.MainWindow
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at com.instantiations.utils.reflect.ProjectClassLoader.findClass(ProjectClassLoader.java:153)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at com.swtdesigner.model.converter.ExpressionConverter.getClassByName(ExpressionConverter.java:1079)
   at com.swtdesigner.model.converter.ExpressionConverter.toValue(ExpressionConverter.java:140)
   at com.swtdesigner.model.converter.ExpressionConverter.toValueAutoConverter(ExpressionConverter.java:1016)
   at com.swtdesigner.model.converter.ExpressionConverter.getArgumentTypesAndValues(ExpressionConverter.java:1032)
   at com.swtdesigner.model.converter.ExpressionConverter.convertMethodInvocation(ExpressionConverter.java:838)
   at com.swtdesigner.model.converter.ExpressionConverter.toValue(ExpressionConverter.java:152)
   at com.swtdesigner.model.converter.MulticastConverter.toValue(MulticastConverter.java:47)
   at com.swtdesigner.model.properties.GenericProperty.toValue(GenericProperty.java:218)
   at com.swtdesigner.model.properties.GenericProperty.getPropertyState(GenericProperty.java:548)
   at com.swtdesigner.model.properties.GenericProperty.getPropertyState(GenericProperty.java:534)
   at com.swtdesigner.model.properties.GenericProperty.getNonDefaultValue(GenericProperty.java:194)
   at com.swtdesigner.model.swing.JavaBeanInfo.applyPropertyFromPropertyDescriptor(JavaBeanInfo.java:2787)
   at com.swtdesigner.model.swing.JavaBeanInfo.applyPropertiesFromPropertyDescriptors(JavaBeanInfo.java:2753)
   at com.swtdesigner.model.swt.widgets.control.ControlInfo.applyProperties(ControlInfo.java:744)
   at com.swtdesigner.model.swt.widgets.control.ControlInfo.createControl(ControlInfo.java:691)
   at com.swtdesigner.model.swt.widgets.composite.AbstractCompositeInfo.createChildrenControls(AbstractCompositeInfo.java:412)
   at com.swtdesigner.model.swt.widgets.composite.AbstractCompositeInfo.createControl(AbstractCompositeInfo.java:384)
   at com.swtdesigner.model.swt.widgets.composite.AbstractCompositeInfo.createChildrenControls(AbstractCompositeInfo.java:412)
   at com.swtdesigner.model.swt.widgets.composite.AbstractCompositeInfo.createControl(AbstractCompositeInfo.java:384)
   at com.swtdesigner.model.swt.widgets.item.ControlItemInfo.createControlOnItem(ControlItemInfo.java:169)
   at com.swtdesigner.model.swt.widgets.composite.TabItemInfo.createTabItem(TabItemInfo.java:62)
   at com.swtdesigner.model.swt.widgets.composite.TabFolderInfo.createSingleControl(TabFolderInfo.java:84)
   at com.swtdesigner.model.swt.widgets.control.ControlInfo.createControl(ControlInfo.java:689)
   at com.swtdesigner.model.swt.widgets.composite.AbstractCompositeInfo.createControl(AbstractCompositeInfo.java:361)
   at com.swtdesigner.model.swt.widgets.composite.AbstractCompositeInfo.createChildrenControls(AbstractCompositeInfo.java:412)
   at com.swtdesigner.model.swt.widgets.composite.AbstractCompositeInfo.createControl(AbstractCompositeInfo.java:384)
   at com.swtdesigner.model.swt.jface.advanced.ApplicationWindowInfo$InternalApplicationWindow.createContents(ApplicationWindowInfo.java:459)
   at org.eclipse.jface.window.Window.create(Window.java:426)
   at com.swtdesigner.model.swt.jface.advanced.ApplicationWindowInfo.createGUIComponent(ApplicationWindowInfo.java:294)
   at com.swtdesigner.model.JavaInfo$18.execute(JavaInfo.java:5608)
   at com.swtdesigner.model.swing.properties.custom.DesignTimeHelper.execute(DesignTimeHelper.java:54)
   at com.swtdesigner.model.JavaInfo.notifyPropertyChanged(JavaInfo.java:5603)
   at com.swtdesigner.model.JavaInfo.notifyPropertyChanged(JavaInfo.java:5584)
   at com.swtdesigner.gef.common.property.DesignerEditorPropertyComposite.handleRootNodeSelected(DesignerEditorPropertyComposite.java:662)
   at com.swtdesigner.gef.common.property.DesignerEditorPropertyComposite.updatePropertyComposite(DesignerEditorPropertyComposite.java:865)
   at com.swtdesigner.gef.DesignerEditor.parseCompilationUnit(DesignerEditor.java:1170)
   at com.swtdesigner.gef.DesignerEditor.bufferChanged(DesignerEditor.java:2086)
   at org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter.fireBufferChanged(DocumentAdapter.java:528)
   at org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter.documentChanged(DocumentAdapter.java:521)
   at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:696)
   at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:673)
   at org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:658)
   at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:723)
   at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1081)
   at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:151)
   at org.eclipse.text.undo.DocumentUndoManager$UndoableTextChange.undoTextChange(DocumentUndoManager.java:143)
   at org.eclipse.text.undo.DocumentUndoManager$UndoableTextChange.undo(DocumentUndoManager.java:262)
   at org.eclipse.core.commands.operations.DefaultOperationHistory.doUndo(DefaultOperationHistory.java:415)
   at org.eclipse.core.commands.operations.DefaultOperationHistory.undo(DefaultOperationHistory.java:1268)
   at org.eclipse.ui.operations.UndoActionHandler.runCommand(UndoActionHandler.java:78)
   at org.eclipse.ui.operations.OperationHistoryActionHandler$4.run(OperationHistoryActionHandler.java:314)
   at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:369)
   at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313)
   at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:495)
   at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog.access$6(TimeTriggeredProgressMonitorDialog.java:1)
   at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog$2.run(TimeTriggeredProgressMonitorDialog.java:203)
   at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
   at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog.run(TimeTriggeredProgressMonitorDialog.java:216)
   at org.eclipse.ui.operations.OperationHistoryActionHandler.run(OperationHistoryActionHandler.java:329)
   at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
   at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
   at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
   at org.eclipse.core.commands.Command.executeWithChecks(Command.java:475)
   at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:429)
   at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:165)
   at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470)
   at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:821)
   at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:879)
   at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:568)
   at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510)
   at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1141)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:937)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:962)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:947)
   at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:975)
   at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:971)
   at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1285)
   at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3772)
   at org.eclipse.swt.widgets.Control.windowProc(Control.java:3672)
   at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:291)
   at org.eclipse.swt.widgets.Display.windowProc(Display.java:4351)
   at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
   at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2265)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3291)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
   at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
   at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
   at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
   at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
   at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
   at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
   at org.eclipse.equinox.launcher.Main.run(Main.java:1173)


-Alex
Alex Senkevitch
 
Posts: 4
Joined: Mon Jan 21, 2008 4:22 pm

Re: Images not displaying in Buttons in Design mode

Postby Eric Clayberg » Thu Jan 24, 2008 8:27 pm

A ClassNotFoundException could certainly account for your image problem (if the class can't be found, no image can be found relative to that class).

The three main sources of a ClassNotFoundException problem are:

1) a classpath problem (can't find the .class file)

2) a compilation problem (.class file does not exist)

3) JDK-level incompatibility problem (older JVM can't load .class file created by newer JDK)

#1 is unlikely, if the class is local.

#2 can happen if you have Eclipse's aut build turned off, or if something else is preventing compilation. Forcing a rebuild can fix this.

#3 can be the most frustrating as it is the least obvious. It happens, for example, if you compile your code using JDK 1.5 or 1.6 and then run Eclipse using a 1.4 or 1.5 JVM (which can't load the newer .class files).

Based on your symptoms, it was almost certainly #2 or #3. Changing the source level would force a global rebuild.
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

Re: Images not displaying in Buttons in Design mode

Postby Alex Senkevitch » Thu Jan 24, 2008 9:52 pm

Fair enough and there you have it. Well, as is the case in many other areas of layered systems, I guess a recompile is once again the answer.

Thanks for the help.

-Alex
Alex Senkevitch
 
Posts: 4
Joined: Mon Jan 21, 2008 4:22 pm

Re: Images not displaying in Buttons in Design mode

Postby Eric Clayberg » Fri Jan 25, 2008 11:21 am

Yes. Rebuilding your project is always a good idea, if you are seeing ClassNotFoundException problems.

That is one of the first things we suggest in our FAQ.
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 SWT Designer

Who is online

Users browsing this forum: No registered users and 2 guests