maroun Adolf wrote:Hi all,
I made an interface using SWT, it includes 14 buttons with text values respectively : Element_1, Element_2, ..., Element_14.
I want to write event handlers on each button stating that : when a button is clicked, the text "Element_1" showing in the button disappears, and the user enters the new text suppose : "new text".
after typing for example "new text" he clicks enter, and the button is now having the text "new text" instead of "Element_1"
Thanks guys
Hi Adolf,
You can do it as per below steps
1.register your button to selectionListener,
2.Add code in the WidgetSelected event to invoke a custom Input dialog.
3.In custom Input dialog create input text field(where user can input text)
4.Reset the button text field with the returned value from Custom Dialog(do remember to resize the button if text is bigger)
button.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent event) {
//text.setText("No worries!");
final InputDialog ip = new InputDialog(shell);//Custom Dialog
button.setText(ip.open());
}