Search code examples
imagej

How to select row in ImageJ ResultsTable?


From an ImageJ plugin, I would like to highlight a row in a ResultsTable, like when the row is clicked with the mouse. I suppose that the function ResultsTable.selectRow(Roi roi) can do this, but I do not know how to specify the row number using a Roi. How to create a Roi for this?


Solution

  • Here is a code snippet to select a row by index:

    import java.awt.Frame;
    import ij.WindowManager;
    import ij.text.TextWindow;
    ...
    int index = ...; // row index to highlight
    Frame frame = WindowManager.getFrame("Results");
    ((TextWindow)frame).getTextPanel().setSelection(index, index);
    

    I adapted it from the ResultsTable source code.