Here is the code.
Now, there are 3 toolItem and 2 toolBar and 2 Coolbar.
In the designer and when i test de form, i dont see the second image. but when i run from eclipse the application, it appears. i cant see the image that i cant see in the design.
(THE OPTION IN THE PREFERENCES IN UNCHECKED)
package src;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import com.swtdesigner.SWTResourceManager;
- Code: Select all
public class Interface {
protected Shell shell;
/**
* Launch the application
*
* @param args
*/
public static void main(String[] args) {
try {
Interface window = new Interface();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window
*/
public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
/**
* Create contents of the window
*/
protected void createContents() {
shell = new Shell();
shell.setSize(500, 375);
shell.setText("SWT Application");
final CoolBar coolBar = new CoolBar(shell, SWT.NONE);
coolBar.setBounds(0, 0, 205, 22);
final CoolItem newItemCoolItem = new CoolItem(coolBar, SWT.PUSH);
newItemCoolItem.setText("New item");
final ToolBar toolBar = new ToolBar(coolBar, SWT.FLAT);
newItemCoolItem.setControl(toolBar);
final ToolItem newItemToolItem = new ToolItem(toolBar, SWT.PUSH);
newItemToolItem.setImage(SWTResourceManager.getImage(Interface.class,
"icons/debug_exec.gif"));
final ToolItem newItemToolItem_1 = new ToolItem(toolBar, SWT.PUSH);
newItemToolItem_1.setImage(SWTResourceManager.getImage(Interface.class,
"icons/new_wiz.gif"));
//
SWTResourceManager.fixCoolBarSize(coolBar);
final CoolItem newItemCoolItem_1 = new CoolItem(coolBar, SWT.PUSH);
newItemCoolItem_1.setText("New item");
final ToolBar toolBar_1 = new ToolBar(coolBar, SWT.FLAT);
newItemCoolItem_1.setControl(toolBar_1);
final ToolItem newItemToolItem_2 = new ToolItem(toolBar_1, SWT.PUSH);
newItemToolItem_2.setImage(SWTResourceManager.getImage(Interface.class,
"icons/prop_ps.gif"));
}
}
Sometimes, i dont see the image in the designer nor when i run the application. And sometimes i see all the images in the designer, but when i run the application, it desappears. (This things happened to me in different projects)
I hope for your response.
Thanks
Eric Clayberg wrote:danireb wrote:In windows/Preferences in Eclipse, in the Designer preferences. I checked "Create every component in its own block" and then all started to work fine.
Hmmm. That should not have any effect at all. In my example, that option was turned off.
We would really need to see your original code in order to try and reproduce the problem (or tell you why it is occurring).
- Code: Select all