Public Accessor of ScrollbarWithLabel in StackWindow

Hi there,

We are using the StackWindow to make our program in nuclear medicine.

In our program we made our own scrollbar for the image stack to handle our custom workflow (our program ask the user to draw ROI on a dataset of N stacks so at each step we replace the ImagePlus form this window and we wanted a scroll bar that manage steps accross differents steps)…

We wanted to remove the original ScrollbarWithLabel element from the StackWindow but the element is private.

Is it possible to change the visibility of the ScrollbarWithLabel as protected (we inherit this class), or make an public getter/Setter or make a method to remove it from the stack window ?

I think this question is directly on the scope for @Wayne,

Best regards,

Salim

Hello Salim -

I do not have an answer to your specific question, but I suggest
a work-around, below.

As a work-around, you can use reflection in java to access and
manipulate private fields and methods.

Here’s an example in a post of mine where I use this technique
with ImageJ code:

This post is not primarily about private-field access, but I use
it in the ResulsTable2.java code to access a private field in
ResultsTable2's superclass, ImageJ’s ResultsTable.

And here is one of many stackoverflow threads about this
technique:

Access to private inherited fields via reflection in Java

Thanks, mm

Thanks @mountain_man for your awnser,
It could be possible to do this way but it will be very sensitive to the StackWindow class update, if the order of variable declaration change in the code it will break everything.

For this long term project I would want something more reliable …

The StackWindow.animationSelector variable in the latest daily build (1.52p35) is protected. The other ScrollbarWithLabel variables (cSelector, zSelector and tSelector) were already protected.

1 Like

Thank you so much !
Best regards,
Salim