invisible SWT-composite when running as Bean or Application [message #68763] |
Fri, 22 October 2004 23:48 |
ronny Messages: 46 Registered: July 2009 |
Member |
|
|
Hello,
I've got the problem that a SWT-class shows a composite correctly in the VE
and also in that "preview-window" out of the Eclipse-window, but the
composite isn't shown when running the class as Bean or Application.
The composite is set visible and I gave it a red background-color and set a
button on it. Everything is invisible!
Perhaps you can give me a tip here?
Here is an example-class:
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
public class Testclass2 {
private org.eclipse.swt.widgets.Shell sShell = null;
private Composite composite = null;
private Button button = null;
/**
* This method initializes composite
*
*/
private void createComposite() {
composite = new Composite(sShell, SWT.NONE);
button = new Button(composite, SWT.NONE);
button.setBounds(new org.eclipse.swt.graphics.Rectangle(20,23,34,18));
composite.setBackground(org.eclipse.swt.widgets.Display.getD efault().getSystemColor(org.eclipse.swt.SWT.COLOR_RED));
}
public static void main(String[] args) {
/* Before this is run, be sure to set up the following in the launch
configuration
* (Arguments->VM Arguments) for the correct SWT library path.
* The following is a windows example:
*
-Djava.library.path=" installation_directory\plugins\org.eclipse.swt.win32_3.0.0\o s\win32\x86 "
*/
org.eclipse.swt.widgets.Display display =
org.eclipse.swt.widgets.Display.getDefault();
Testclass2 thisClass = new Testclass2();
thisClass.createSShell() ;
thisClass.sShell.open();
while (!thisClass.sShell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep ();
}
display.dispose();
}
/**
* This method initializes sShell
*/
private void createSShell() {
sShell = new org.eclipse.swt.widgets.Shell();
GridLayout gridLayout1 = new GridLayout();
createComposite();
sShell.setSize(new org.eclipse.swt.graphics.Point(300,200));
sShell.setText("Shell");
sShell.setLayout(gridLayout1);
gridLayout1.numColumns = 2;
}
}
|
|
|
Re: invisible SWT-composite when running as Bean or Application [message #68947 is a reply to message #68763] |
Sun, 24 October 2004 17:16 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
There was a bug in the original New Class wizard for SWT shell (fixed in
1.0.1.1). It put the initialize() method before all of the settings
instead of at the end. This causes a problem on GTK because the layout
occurs on the setSize, but at the time of the setSize there is nothing
to layout, so it chooses some minimal layout.
The fix for you is to simply move the setSize to the end of the
initialize method. Everything should work fine after this.
--
Thanks,
Rich Kulp
|
|
|
|
Re: invisible SWT-composite when running as Bean or Application [message #602310 is a reply to message #68763] |
Sun, 24 October 2004 17:16 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
There was a bug in the original New Class wizard for SWT shell (fixed in
1.0.1.1). It put the initialize() method before all of the settings
instead of at the end. This causes a problem on GTK because the layout
occurs on the setSize, but at the time of the setSize there is nothing
to layout, so it chooses some minimal layout.
The fix for you is to simply move the setSize to the end of the
initialize method. Everything should work fine after this.
--
Thanks,
Rich Kulp
|
|
|
|
Powered by
FUDForum. Page generated in 0.04446 seconds