问题
I am writing a plugin for ImageJ that scans the pixels of a desired line for brightness over a series of frames in an AVI video. The data is displayed in 2D graph for the active video frame, pixels on the x-axis and intensity on the y-axis.
I want the graph to update itself to show the data for the active frame in the StackWindow (Where the frame is displayed). This is controlled by the slider in the window. I looked into this and found information on the AdjustmentListener class, which I can probably use to check when the slider is adjusted. How do I do this?
Link to the StackWindow class
回答1:
As far as I know there isn't a particularly elegant way of doing this. The best way is probably to iterate over everything returned by getComponents
on your StackWindow
and add an AdjustmentListener
to that component if it's a Scrollbar
. You can find a couple of examples here and here, although those examples are more general than what you need.
来源:https://stackoverflow.com/questions/6735795/java-how-to-add-a-listener-in-imagej-plugin