This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SWT and AWT



as i understand it there are some insurmountable problems required to
implement the awt interface using swt. one of these is the fact that swt
widgets cannot be reparented,


You are correct that you cannot directly subclass a SWT widget. The AWT classes would have to be thin "interface" like classes that wrap the actual SWT control:

public class Button
{
   private swt.eclipse.swt.widget.Button swtButton;
   private String text;
   ....(more properties)

   public void setText(String text)
   {
      this.text = text;
   }
   ...(more methods)
}

and must be constructed in the context of
their parent (presumably "because this is the way windows does it").


Think of SWT composites as AWT containers. You dont actually create an instance of the SWT object (swtButton above) until you "add" it to the AWT container. So, the AWT Component class would probably have something as such:

public abstract class Component
{
   protected abstract void createWidget(Container container);
}

which extended by my Button example:

protected void createWidget(Container container)
{
swtButton = new org.eclipse.swt.widget.Button(container.getComposite, SWT.NONE);
}


Theres probably a better way of doing this but its what I came up with in a couple minutes.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]