ImageJ opening imagePlus window as an internal frame inside a desktopPane

╄→尐↘猪︶ㄣ 提交于 2019-12-18 09:45:47

问题


I am having some trouble in ImageJ with one of its files. Basically set up a desktop pane that analyzes and opens images. But when the program opens the image it opens it as a separate JFrame. I would like to be an internal JFrame. So basically the image opens up in the desktop pane. I have tried a couple of things like creating a internal frame class and adding the win to the desktopPane but nothing seems to work it still opens it as a separate JFrame. I was wondering if anyone knows how to do this.

This is my code (this function is just calling .show() to display the image, the code for the actual JFrame that opens the window is in ImageWindow.java):

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

FileOpener open = new FileOpener(file);     

ImagePlus fopen = open.open(false);

 if(fopen != null){
    BufferedImage openImage = fopen.getBufferedImage();
    new ImagePlus(path,openImage).show(desktop); //This functions displays the image
    ImagePlus newImage = new ImagePlus(path,openImage);
    img = newImage;


 }
 frame.setVisible(false);

}

回答1:


The creation of a new JFrame is hardcoded into ImageJ's ImagePlus class:

if (stackSize>1)
    win = new StackWindow(this);
else
    win = new ImageWindow(this);

If you want to adapt the GUI, you can extend the ImageWindow or StackWindow classes. See the Trainable Weka Segmentation plugin for a nice example.

Alternatively, use the data structures of ImageJ2, namely ImgLib's ImgPlus. These are designed to be independent of any user interface.



来源:https://stackoverflow.com/questions/23528247/imagej-opening-imageplus-window-as-an-internal-frame-inside-a-desktoppane

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!