Projects Tools Projects Hosted Projects
|
import java.awt.Color;
Note also that starting with Eclipse 3.2M1, a new method is available to retrieve the embedded AWT Frame in a Composite following this enhancement request. The method is SWT_AWT.getFrame(Composite). It returns the embedded for a Composite, if there is one. A patch is also attached that provides the same feature (albeit in a somewhat fragile way) for Eclipse 3.x, and that can be implemented as a static method in any class. Comments:From ania - 7/18/05 2:12 AM sorry - simple mistake - there supposed to be 'swt library' in the first line ofthe previous post
From ania - 7/18/05 2:11 AM I just wanted to complain about my version of awt library. I have no new_Panel AND new_Frame implemented in the swt package. All examples for applets using SWT that I found in the Internet were using at least one of those classes. Is there any other way to build such an applet? Otherwise, where can I find version of SWT that has those classes? From exquisitus - 5/23/05 5:32 AM The code sample does not compile as it is using method new_Panel, which does not exist in SWT_AWT class. Here is a working version:
public class Main {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Main");
shell.setBounds(0, 0, 200, 250);
Composite swt = new Composite(shell, SWT.NONE);
Label swtLabel = new Label(swt, SWT.NONE);
swtLabel.setText("swt label");
swtLabel.setBounds(10, 10, 70, 20);
swt.setBounds(0, 0, 200, 250);
swt.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
Composite SWT_AWT_container = new Composite(swt, SWT.EMBEDDED);
SWT_AWT_container.setBounds(0, 50, 200, 150);
Panel awt = new Panel();
Frame awtFrame = SWT_AWT.new_Frame(SWT_AWT_container);
awtFrame.add(awt);
awt.setBackground(Color.red);
awt.setBounds(0, 0, 200, 150);
java.awt.Label awtLabel = new java.awt.Label("AWT Label");
awtLabel.setBounds(0, 0, 70, 20);
awt.add(awtLabel);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
From youkenkin - 10/17/04 9:32 PM how can i use swt in my applet?
can you help me?
youkenkin@t-xcs.com Last Modified 6/21/06 9:16 AM | Hide Tools |