Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to get value from RCP forms
How to get value from RCP forms [message #992504] Fri, 21 December 2012 20:23 Go to next message
davy hu
Messages: 2
Registered: December 2012
Junior Member
I created a form by using the forms API:

My question is how can write the code to get the values of "first name" and "last name" when "submit" button is clicked. Theanks.

here is my code in

public class View extends ViewPart {
public static final String ID = "com.test.forms.view";

private TableViewer viewer;

public void createPartControl(Composite parent) {
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
Composite client = toolkit.createComposite(parent, SWT.WRAP);
Table t = toolkit.createTable(client, SWT.NULL);
viewer = new TableViewer(t);
viewer.setContentProvider(new ArrayContentProvider());

Form form = toolkit.createForm(parent);
Composite composite = form.getBody();
composite.setLayout (new GridLayout(2, true));

Label lblFirstName = toolkit.createLabel(composite, "First Name");
Label lblLastName = toolkit.createLabel(composite, "Last Name");
Text txtFirstName = toolkit.createText(composite, "");
Text txtLastName = toolkit.createText(composite, "");
Button b = toolkit.createButton(composite, "Submit", SWT.PUSH);

public void setFocus() {

Re: How to get value from RCP forms [message #994443 is a reply to message #992504] Thu, 27 December 2012 10:30 Go to previous messageGo to next message
Simon Scholz is currently offline Simon Scholz
Messages: 73
Registered: April 2012
Location: Germany
Hello davy,

you just have to add an selection listener to the button in order to get to know when the button is clicked.

And then use the txtFirstName.getText() and txtLastName.getText() methods to get the values.

By the way the FormToolkit also does only create SWT widgets internally.

Best regards,

Re: How to get value from RCP forms [message #995952 is a reply to message #994443] Mon, 31 December 2012 16:15 Go to previous message
davy hu
Messages: 2
Registered: December 2012
Junior Member
Thank you very much Simon! I got it now!
Previous Topic:How can i add an perspective from a plugin to my e4 application model?
Next Topic:Databinding, IListener, and Data Retention post application close
Goto Forum:

Current Time: Thu Oct 23 06:05:01 GMT 2014

Powered by FUDForum. Page generated in 0.02031 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software