1

I have looked everywhere without finding an answer. Sorry if this has been posted before.

I know how to do a clickable URL when the cell itself only contains a URL, which basically just attaching a mouselistener to a table and getting which Row is clicked and getting the value. So that's easy.

My issue is that I have several links inside one cell so I need different things to happen when the user click on those links. For example:

class MyTableModel extends AbstractTableModel {

@Override
        public Object getValueAt(int rowIndex, int columnIndex) {

             switch (columnIndex) {
             case 0:
                  return "<html><a href='www.test.com'>test1</a> <a href='www.test2.com'>test2</a></html>";

             default:
                    throw new IndexOutOfBoundsException();
             }    
        }
}

So I have two different links that need to be next to eachother. How do I find out which one of them got clicked?

Finding out which row was clicked is not difficult, but how do I find out which element inside the row was clicked?

Edit: Can't use JEditorPane since it messes up the objects inside the cells.

Omid
  • 823
  • 1
  • 11
  • 31
  • Duplicate of [html issues with images in JTable](http://stackoverflow.com/questions/16209322/html-issues-with-images-in-jtable). – trashgod Apr 25 '13 at 19:51
  • Its not duplicaste. This is for multiple urls being clicked in cells, the other one is for positioning HTML elements (images) without a line brake. – Omid Apr 25 '13 at 20:02

1 Answers1

0

For that you have to make cell as JEditorpane. As you mentioned your using cell(may be its Jtable) make the jtable custom and editable cells.

Chk out this links:

JtextPane

Tutorial

Ash..
  • 1
  • 5