dynamically add listener to a SWT widget

Ads

 
 

Share on Google+Share on Google+

shivangi gupta
dynamically add listener to a SWT widget
0 Answer(s)      4 years and 11 months ago
Posted in : Swing AWT

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..:)

Ads
View Answers
Ads









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
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>
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
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
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
add
How to add two int numbers in Java Example  How to add two int numbers in Java Example  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers
add
Java Example to add two numbers  Java Example to add two numbers  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main
add
Java Program to add two numbers  Java Program to add two numbers  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main
add
How to add two numbers in Java  add two number   Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers { public static void main(String[] args
add
add two no in Java  Java Add Example that accepts two integer from the user and find their sum  Here is a java example that accepts two integer from the user and find their sum. import java.util.*; class AddNumbers
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
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
Listener ports - JMS
Listener ports Error in JMS  Hi, I am getting an listener ports error in JMS. Does anyone have solution
Java event-listener
Java event-listener  What is the relationship between an event-listener interface and an event-adapter class
Artifacts of swt
List of Artifacts of swt maven depenency
Version of nanocontainer-swt>nanocontainer-swt dependency
List of Version of nanocontainer-swt>nanocontainer-swt dependency
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
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
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
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
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
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

Ads

 
Advertisement null

Ads