http://imagej.273.s1.nabble.com/Showing-progress-bar-when-opening-images-tp5018335p5018343.html
Thank you very much for your answer. Although I have no experience
much effort.
Ignacio.
>> On Mar 21, 2017, at 5:22 AM, Ignacio García González <
[hidden email]> wrote:
>>
>>> ImageJ automatically displays a progress bar as needed when reading and writing TIFF images and stacks.
>>>
>>> -wayne
>> Thank you for your quick reply. However, my concern is that I cannot see this progress bar when opening the image from another frame, and I do not find the way to do it. I even looked through the source code to try to understand how the ProgressBar works.
> You have to open the images in the background using a separate thread, as in the following example.
>
> -wayne
>
>
> import ij.*;
> import ij.process.*;
> import ij.gui.*;
> import java.awt.*;
> import java.awt.event.*;
> import ij.plugin.*;
> import ij.plugin.frame.PlugInFrame;
> import java.io.File;
> import java.io.*;
>
> public class Separate_Thread extends PlugInFrame implements ActionListener, Runnable {
>
> static private Button btnOpen=new Button("Open");
>
> public Separate_Thread() {
> super("Open file test");
> btnOpen.addActionListener(this);
> add(btnOpen);
> setResizable(false);
> pack();
> GUI.center(this);
> setVisible(true);
> }
>
> public void actionPerformed(ActionEvent e) {
> Object source = e.getSource();
> if (source==btnOpen) {
> Thread thread = new Thread(this, "Open Image");
> thread.start();
> }
> }
>
> public void run() {
> ImagePlus imp=IJ.openImage("");
> imp.show();
> }
>
> }
>
>
>> The following piece of code opens an image, but the bar is not displayed (running under Windows 10 with 64 bit Java 1.8.0_121). I was opening 200 Mb files, which displayed the progress bar when opening directly from ImageJ.
>>
>> import ij.*;
>> import ij.process.*;
>> import ij.gui.*;
>> import java.awt.*;
>> import java.awt.event.*;
>> import ij.plugin.*;
>> import ij.plugin.frame.PlugInFrame;
>> import java.io.File;
>> import java.io.*;
>>
>> public class Test1_ extends PlugInFrame implements ActionListener {
>>
>> static private Button btnOpen=new Button("Open");
>>
>> public Test1_() {
>> super("Open file test");
>> btnOpen.addActionListener(this);
>> add(btnOpen);
>> setResizable(false);
>> pack();
>> GUI.center(this);
>> setVisible(true);
>> }
>>
>> public void actionPerformed(ActionEvent e) {
>> Object source=e.getSource();
>> if (source==btnOpen) {
>> ImagePlus imp=IJ.openImage(filename);
>> imp.show();
>> }
>> }
>> }
>>
>> Greetings,
>>
>> Ignacio.
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html> .
>