dynamically add listener to a SWT widget

dynamically add listener to a SWT widget

hello,

I am using SWT technology for my project,there is mail facility, i want attachment of multiple files.first link is created, but other links have to be generated dynamically as we do in gmail,and there should be a listener for every link.here is the code..

final Link attachLink = attachFileLink(linkCanvas);
        attachLink.setText("<a>"+CommandIds.ATTACH_FILE+"</a>");
        attachLink.addListener(SWT.Selection, new Listener() {
          public void handleEvent(Event event) { 
             String path = null;
            if(event.text.trim().equals(CommandIds.ATTACH_FILE))
            {
                path =  fileSelector(parent.getShell());
                if(path != null && !path.equals("")) {
                     Button checkBox = new Button (linkCanvas , SWT.CHECK);
                     attachLink.setText(path);
                     checkBox.setSelection(true);
                     if(sNo < 5) {
                         anotherLink[sNo] = attachFileLink(linkCanvas);
                         anotherLink[sNo].setText("<a>"+CommandIds.ATTACH_ANOTHER_FILE+"</a>");
                     }
                 linkCanvas.pack();
                 linkCanvas.redraw();
                }
            }
          }
        });
        final Listener attachLinkListsner = new Listener() {
            public void handleEvent(Event event) {
                String path = null;
                if(event.text.trim().equals(CommandIds.ATTACH_ANOTHER_FILE)) {
                    path =  fileSelector(parent.getShell());
                    if(path != null && !path.equals("")) {
                         anotherLink[sNo].setText(path);
                         checkBox[sNo] = new Button(linkCanvas , SWT.CHECK);
                         checkBox[sNo].setSelection(true);
                         sNo++;
                         if(sNo < 5){
                             anotherLink[sNo] = attachFileLink(linkCanvas);
                             anotherLink[sNo].setText("<a>"+CommandIds.ATTACH_ANOTHER_FILE+"</a>");
                         }
                         linkCanvas.pack();
                         linkCanvas.redraw();
                    }
                }
            }
        };

but how to add listener to anotherLink, beacause it will be created after clicking on the first link.If there is any other way to attach muliple files to a mail, then please let me know. i have searched on google a lot, but i din't find out the right one.

Thanx..:)

View Answers









Related Tutorials/Questions & Answers:
dynamically add listener to a SWT widget
dynamically add listener to a SWT widget  hello, I am using SWT... files.first link is created, but other links have to be generated dynamically as we do in gmail,and there should be a listener for every link.here is the code
JavaScript add row dynamically to table
JavaScript add row dynamically to table  ... to add row to a table dynamically then we can also do this with the JavaScript code. In this example we will describe you how to add row dynamically to the table
Advertisements
how to add data dynamically from database into a dropdown list in a jsp
how to add data dynamically from database into a dropdown list in a jsp ... get dynamically from the database and whenever a new person has registered his name should also be included in the list dynamically and any updating
how to dynamically add text boxes with add and remove link based on drop down choices, if a particular choice is selected.
how to dynamically add text boxes with add and remove link based on drop down choices, if a particular choice is selected.  how to dynamically add text boxes with add and remove link based on drop down choices, if a particular
How to add dynamically rows into database ?Need help pls
How to add dynamically rows into database ?Need help pls  Hi everyone, I really have a problem of insert multiple rows into the database.Now i can...; <input type="button" value="Add Row" onclick="addRow();" /> <input
add text box and select list dynamically and get its value to store it into database using jsp request parameter
add text box and select list dynamically and get its value to store it into database using jsp request parameter  its very helpful when you have only dynamically added text field but want code to retrive value of dynamically
Java listener
Java listener  What is source and listener
SWT
SWT       Calendar Example SWT allows to create Calendar by using... in the layout.    Draw Calendar in SWT SWT allows
Add/Remove Rows Dynamically with drop down list in html table using php
Add/Remove Rows Dynamically with drop down list in html table using php ...;th>Name</th> <th>Add Field</th> <...="Add" id="nameselbtn" onclick="javascript:addrow();" /></td>
Version of swt>swt-macosx dependency
List of Version of swt>swt-macosx dependency
Version of swt>swt-mozilla dependency
List of Version of swt>swt-mozilla dependency
Maven Dependency swt-macosx >> 3.0m7
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-macosx version3.0m7 in your project
Maven Dependency swt-mozilla >> 3.0m7
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-mozilla version3.0m7 in your project
Event listener in JavaScript with example
Event listener in JavaScript with example  What is event listener in JavaScript? Can anyone please post an example of Event listener?? Thanks in Advance
ModuleNotFoundError: No module named 'listener'
ModuleNotFoundError: No module named 'listener'  Hi, My Python... 'listener' How to remove the ModuleNotFoundError: No module named 'listener... to install padas library. You can install listener python with following
Listener ports - JMS
Listener ports  I am getting the following error on my server. Please...] 00000150 MDBListenerIm I WMSG0043I: MDB Listener CLSMGUncorrelatedMDBListenerPortA...:25:392 CST] 000000b8 MDBListenerIm I WMSG0042I: MDB Listener
Maven Dependency nanocontainer-swt >> 1.0-beta-1
You should include the dependency code given in this page to add Maven Dependency of nanocontainer-swt >> nanocontainer-swt version1.0-beta-1 in your project
Maven Dependency nanocontainer-swt >> 1.0-beta-4
You should include the dependency code given in this page to add Maven Dependency of nanocontainer-swt >> nanocontainer-swt version1.0-beta-4 in your project
Listener ports - JMS
Listener ports Error in JMS  Hi, I am getting an listener ports error in JMS. Does anyone have solution
Artifacts of swt
List of Artifacts of swt maven depenency
Version of swt>swt-gtk-mozilla dependency
List of Version of swt>swt-gtk-mozilla dependency
Version of swt>swt-linux-gtk dependency
List of Version of swt>swt-linux-gtk dependency
Version of nanocontainer-swt>nanocontainer-swt dependency
List of Version of nanocontainer-swt>nanocontainer-swt dependency
Is it possible in SWT ?
Is it possible in SWT ?  I want drop down like google search (ie, when we type one letter then the word start with that are displayed). when the drop... do this in SWT ? Thanks
Java event-listener
Java event-listener  What is the relationship between an event-listener interface and an event-adapter class
Maven Dependency swt-linux-gtk >> 3.0m8
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-linux-gtk version3.0m8 in your project
Maven Dependency swt-gtk-mozilla >> 3.0.1
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-gtk-mozilla version3.0.1 in your project
Maven Dependency swt-gtk-mozilla >> 3.0m8
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-gtk-mozilla version3.0m8 in your project
Maven Dependency swt-linux-gtk >> 3.0.1
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-linux-gtk version3.0.1 in your project
Maven Dependency swt-linux-gtk >> 3.0m7
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-linux-gtk version3.0m7 in your project
httpsession listener - JSP-Servlet
httpsession listener  i want to see the example of httpsession listener where it is counting how many times the session has been created
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
dynamically writing text javascript
dynamically writing text javascript  dynamically writing text javascript. Is it possible
Version of swt>swt-linux-gtk-pi dependency
List of Version of swt>swt-linux-gtk-pi dependency
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for penfold-listener version 1.9
-listener version 1.9. You can add these depency in your project to get com.qmetric:penfold-listener:1.9 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for penfold-listener version 1.9
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for penfold-listener version 1.7
-listener version 1.7. You can add these depency in your project to get com.qmetric:penfold-listener:1.7 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for penfold-listener version 1.7
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for penfold-listener version 1.6
-listener version 1.6. You can add these depency in your project to get com.qmetric:penfold-listener:1.6 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for penfold-listener version 1.6
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for penfold-listener version 1.5
-listener version 1.5. You can add these depency in your project to get com.qmetric:penfold-listener:1.5 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for penfold-listener version 1.5
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for penfold-listener version 1.4
-listener version 1.4. You can add these depency in your project to get com.qmetric:penfold-listener:1.4 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for penfold-listener version 1.4
Maven Dependency penfold-listener >> 1.0
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.0 in your project
Maven Dependency penfold-listener >> 1.1
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.1 in your project
Maven Dependency penfold-listener >> 1.2
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.2 in your project
Maven Dependency penfold-listener >> 1.3
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.3 in your project
Maven Dependency penfold-listener >> 1.4
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.4 in your project
Maven Dependency penfold-listener >> 1.5
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.5 in your project
Maven Dependency penfold-listener >> 1.6
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.6 in your project
Maven Dependency penfold-listener >> 1.7
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.7 in your project
Maven Dependency penfold-listener >> 1.9
You should include the dependency code given in this page to add Maven Dependency of com.qmetric >> penfold-listener version1.9 in your project
Maven Dependency swt-linux-gtk-pi >> 3.0.1
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-linux-gtk-pi version3.0.1 in your project
Maven Dependency swt-linux-gtk-pi >> 3.0m7
You should include the dependency code given in this page to add Maven Dependency of swt >> swt-linux-gtk-pi version3.0m7 in your project

Ads