jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes MutiText Input selection using JFACE with the help of + button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "MutiText Input selection using JFACE with the help of + button" Watch "MutiText Input selection using JFACE with the help of + button" New topic

MutiText Input selection using JFACE with the help of + button

Piu Bhattacharya

Joined: Jun 20, 2013
Posts: 1
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.

I agree. Here's the link: http://aspose.com/file-tools
subject: MutiText Input selection using JFACE with the help of + button
It's not a secret anymore!