0

I want to add hyperlink on table item in swt but I can not find any method for it.Now I want to set cursor icon to hand icon when the cursor move on that particular item column.. so that particular item feel like a hyperlink.tell me any suggestion or method of this..

public void drawTable(String[] str) {
    if (str != null) {
        TableItem it1 = new TableItem(table, SWT.NONE);
        int i = str.length;
        String[] tmp = new String[i];
        tmp[0] = str[0];
        tmp[1] = str[1];
        int k = i - 1;
        for (int j = 2; j < i; j++, k--) {
            tmp[j] = str[k];
        }
        it1.setText(tmp);
        for (i = 2; i < str.length; i++) {
            it1.setForeground(i, display.getSystemColor(SWT.COLOR_BLUE));
        }
    }
}
Sorceror
  • 4,835
  • 2
  • 21
  • 35
Ashish Panery
  • 1,196
  • 3
  • 13
  • 24

3 Answers3

2

If you want to add hyperlink to table cell, you'll have to write your own StyledCellLabelProvider see StyledCellLabelProvider snippet for details. It's also similar question to How to add Hyperlink in SWT Table`s column?.

Community
  • 1
  • 1
Sorceror
  • 4,835
  • 2
  • 21
  • 35
0

Use table.addMouseMoveListener.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
  • Thanks for your suggestion but i do not want to make whole table column as hyperlink.I just want table item at column 3 and 4 as hyperlink.I want to addlistener on that tableitem . – Ashish Panery Sep 01 '11 at 15:24
  • @Ashish Panery: Check which item and column are under the mouse in your listener. – Alexey Romanov Sep 01 '11 at 16:45
0

I found that there is no option for making item data as hyperlink. So i just colored my item data and check the coordinate of the point where user click and check that it is in the column or not, which i use as column for hyperlink and do my operation...

Thanks to all. code will paste soon.

Ashish Panery
  • 1,196
  • 3
  • 13
  • 24