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.