[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-swt-dev] Embedding AWT in SWT
|
On WindowsXP, with the line of code commentted, I can see the AWT
components. And I find the following codes in Control
void setBackgroundPixel (int pixel) {
if (background == pixel) return;
background = pixel;
OS.InvalidateRect (handle, null, true);
}
in which I won't know anything about OS.InvalidateRect (handle, null, true);
And Solaris platform may performs differently from Windows platform.
Jozz
Mike Watson wrote:
I tried that. But it doesn't seem to work. Still what difference does
it make when I set the background color of the Composite?
From: jozz <joo@xxxxxxxxxxx>
Reply-To: platform-swt-dev@xxxxxxxxxxx
To: platform-swt-dev@xxxxxxxxxxx
Subject: Re: [platform-swt-dev] Embedding AWT in SWT
Date: Mon, 21 Feb 2005 21:47:41 +0800
Hi,
Maybe you can try composite.setLayout(...)
Jozz
Mike Watson wrote:
Hi All,
I'm new to SWT. I've a specific requirement where I want to embed
AWT components in an SWT shell. I read the documentation and saw the
example code to do the same. I've written a sample code myself, but
it behaves a bit wierd. Here is the code:
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.awt.SWT_AWT;
public class AWTTest {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("AWT Test");
GridLayout gridlayout = new GridLayout();
shell.setLayout(gridlayout);
Composite composite = new Composite(shell, SWT.EMBEDDED);
composite.setLayoutData(new GridData(GridData.FILL_VERTICAL |
GridData.FILL_HORIZONTAL));
//composite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
java.awt.Frame frame = SWT_AWT.new_Frame(composite);
frame.setLayout(new java.awt.BorderLayout());
java.awt.Panel panel = new java.awt.Panel();
panel.setLayout(new java.awt.FlowLayout());
java.awt.Button b = new java.awt.Button("AWT Button");
java.awt.Choice ch = new java.awt.Choice();
ch.addItem("One");
ch.addItem("Two");
java.awt.Checkbox cb = new java.awt.Checkbox("Checkbox");
java.awt.Label label = new java.awt.Label("Label");
java.awt.List list = new java.awt.List();
list.add("One");
list.add("Two");
java.awt.Scrollbar sb = new
java.awt.Scrollbar(java.awt.Scrollbar.HORIZONTAL, 0, 20, 0, 100);
java.awt.TextField tf = new java.awt.TextField(20);
java.awt.TextArea ta = new java.awt.TextArea(5, 15);
panel.add(b);
panel.add(ch);
panel.add(cb);
panel.add(label);
panel.add(list);
panel.add(sb);
panel.add(tf);
panel.add(ta);
frame.add(panel);
Listener exitListener = new Listener() {
public void handleEvent(Event e) {
shell.dispose();
}
};
shell.addListener(SWT.Close, exitListener);
shell.setLocation(300, 100);
shell.setSize(400, 400);
shell.open();
System.out.println(frame.getSize());
while(!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
The code does not display the AWT components. But if I uncomment a
line of code which sets background color of the Composite, the AWT
components become visible. This is happening with SWT 3.0.1 on
Solaris platform. What is the reason for this behavior? What am I
doing wrong?
TIA,
Mike
_________________________________________________________________
Don?t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev
_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how
to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev