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


SwingWT (swingwt.sourceforge.net) does this already with AWT/Swing
interfaces.

On another note, all SWT components do in fact support a setParent()
method - you do need a parent to create the component in the first place
(its part of the SWT widget constructor), but once created you can
reparent them. That's in version 2.1 of SWT (and we're upto 3)

Anyway, I have to agree here - SWT is ok, and I use my stuff so I can
program with Swing and get native widgets with GCJ, but libgcj really 
needs its own implementations of these things due to the licencing of SWT.

Bob

On Mon, Nov 24, 2003 at 01:27:21PM -0500, Stanley Brown wrote:
> 
> >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.

-- 
=====================================================
Robin Rawson-Tetley

Animal Shelter Manager (http://sheltermanager.sf.net)
SwingWT                (http://swingwt.sf.net)

Attachment: pgp00000.pgp
Description: PGP signature


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