Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MutiText Input selection using JFACE with the help of + button  RSS feed

Piu Bhattacharya
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to JFACE and was designing a multitext input in the following way.

composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH));

Label sampletext1=new Label(composite,SWT.NONE);
sampletext1.setText("Provide The names");
names= new Text(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL );

names.setLayoutData(new GridData(GridData.FILL_BOTH));
and it is working fine.

However I wanted to know if I could add a multi user input using a + button. Say a user inputs a name , then if he has one more name to add , he clicks on the + button and another text area opens for him below.

I searched online for this and I found out a suggestion
to add a selection listener on the button that invokes a method that creates a new Composite inside the parent Composite and pack the outermost container (Shell) after the new container is added.

This is the code I am working on now:

button.addSelectionListener(new SelectionListener() {

public void widgetSelected(SelectionEvent event) {



And this is my createCustom Area method looks something like this:

private Composite createCustomArea(Composite c) {

Composite inner = new Composite(c, SWT.NONE);
inner.setLayout(new GridLayout(2, false));
inner.setLayoutData(new GridData(GridData.FILL, GridData.END, true, false));

GridData gd = new GridData(SWT.FILL, SWT.FILL, true,true);

Label l = new Label(inner, SWT.NONE);
l.setText("Label #" + lCount++);

Text t = new Text(inner, SWT.NONE);
return inner;

I am having difficulty in this line [ Display.add(createCustomArea(c));]
On how to call the createCustomArea from the buttonlistener

Any help/comments would be welcome.

Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!