problems with awt

I am in the Middle of implementing a method in a tutorial excercise. The complier flags much of syntax as incorrect, however the code appears fine to me.

below is the method :

publicvoid createPartControl(Composite parent){

Composite top =new Composite(parent, SWT.NONE);

GridLayout layout =new GridLayout();

layout.marginWidth = 0;

layout.marginHeight = 0;

top.setLayout(layout);

transcript =new Text(top, SWT.BORDER | SWT.MULTI | SWT.WRAP);

transcript.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,true));

transcript.setEditable(false);

transcript.setBackground(transcript.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));

transcript.setForeground(transcript.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));

entry =new Text(top, SWT.BORDER | SWT.WRAP);

GridData gridData =new GridData(GridData.FILL, GridData.FILL, true,false);

gridData.heightHint = entry.getLineHeight() * 2;

entry.setLayoutData(gridData);

entry.addKeyListener(Listener)(new KeyAdapter(){

publicvoid keyPressed(KeyEvent event){

if (event.character == SWT.CR){

sendMessage();

event.doit =false;

}

}

});

}

Can anyone see fromthis code anyone obvious errors.

[2104 byte] By [Dash161a] at [2007-11-27 11:05:46]
# 1

Don't be coy. if there are syntax errors what are they?

Hippolytea at 2007-7-29 13:10:52 > top of Java-index,Java Essentials,New To Java...
# 2

> Don't be coy. if there are syntax errors what are

> they?

Sorry. they are

layout.marginWidth cannot be resolved or is not a field

layout.marginHeight cannot be resolved or is not a field

entry.addKeyListener(Listener)(new KeyAdapter() {

public void keyPressed(KeyEvent event) {

if (event.character == SWT.CR) {

sendMessage();

event.doit = false;

}

}

});

the above flags The left-hand side of an assignment must be a variable

Dash161a at 2007-7-29 13:10:52 > top of Java-index,Java Essentials,New To Java...
# 3

> layout.marginWidth cannot be resolved or is not a field

> layout.marginHeight cannot be resolved or is not a field

So, what does that error suggest to you?

Hippolytea at 2007-7-29 13:10:52 > top of Java-index,Java Essentials,New To Java...
# 4

> > layout.marginWidth cannot be resolved or is not a

> field

> > layout.marginHeight cannot be resolved or is not a

> field

>

> So, what does that error suggest to you?

marginWidth and marginHeight don't exist in layout?

Dash161a at 2007-7-29 13:10:52 > top of Java-index,Java Essentials,New To Java...
# 5

> > > layout.marginWidth cannot be resolved or is not

> a

> > field

> > > layout.marginHeight cannot be resolved or is not

> a

> > field

> >

> > So, what does that error suggest to you?

>

> marginWidth and marginHeight don't exist in layout?

Exactly. A good way to find out what does exist is to consult the API documentation. You'll want to bookmark this:

http://java.sun.com/javase/6/docs/api/

Hippolytea at 2007-7-29 13:10:52 > top of Java-index,Java Essentials,New To Java...
# 6

Cheers for the link, do you suppose Sun my have had it depricated?

the reason I ask is that this tutorial is from a book so it must of worked once.

Dash161a at 2007-7-29 13:10:53 > top of Java-index,Java Essentials,New To Java...
# 7

> Cheers for the link, do you suppose Sun my have had

> it depricated?

>

> the reason I ask is that this tutorial is from a book

> so it must of worked once.

You can find that out on the page for GridLayout.

Hippolytea at 2007-7-29 13:10:53 > top of Java-index,Java Essentials,New To Java...
# 8

Thanks for your help

Dash161a at 2007-7-29 13:10:53 > top of Java-index,Java Essentials,New To Java...
# 9

No problem. And don't that me, thank ... THE API!... <wipes tear from eye/>

Hippolytea at 2007-7-29 13:10:53 > top of Java-index,Java Essentials,New To Java...