Login  Register

Re: question about adding component to a ImageWindow

Posted by Patrick Pirrotte on Oct 07, 2008; 3:31pm
URL: http://imagej.273.s1.nabble.com/question-about-adding-component-to-a-ImageWindow-tp3694834p3694837.html

Hi Xin,

Did you extend ImageCanvas as described in Panel_Window example?
(http://rsb.info.nih.gov/ij/plugins/download/Panel_Window.java)

As TextPanel is a subclass of java.awt.Panel, adding a panel should be no
problem...

....

 void addPanel() {
            add(new TextPanel("Title"));
            pack();
      Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
            Point loc = getLocation();
            Dimension size = getSize();
            if (loc.y+size.height>screen.height)
                getCanvas().zoomOut(0, 0);
         }
....

Regards,

Patrick

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of xin
zhang
Sent: 07 October 2008 16:41
To: [hidden email]
Subject: Re: question about adding component to a ImageWindow

Hi, Patrick,

Thanks for the information, what I tried to put in the ImageWindow was
actually an object of ij.text.TextPanel.

So, any idea?

Xin

On Tue, Oct 7, 2008 at 3:27 AM, Patrick Pirrotte
<[hidden email]> wrote:

> Hi Xin,
>
> If you want to extend ImageWindow or ImageCanvas you need to stay in AWT.
> Try replacing JTextPane by java.awt.TextArea.
>
> You can't mix heavyweight components (such as AWT) with lightweight
> components (such as Swing). As ImageJ is written in AWT, inside Frames
> such as ImageWindow/ImageCanvas only AWT components get correctly
> drawn. You can put Swing components into a separate JFrame though, and
> several plugins do so to profit from the larger component library offered
by javax.swing.*.

>
> Regards,
>
> Patrick
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> xin zhang
> Sent: 07 October 2008 00:03
> To: [hidden email]
> Subject: question about adding component to a ImageWindow
>
> Hi,
>
> I am trying to add a TextPanel to an ImageWindow, however, no matter
> how do I set the size of the TextPanel, I always get tiny TextPanel as
> shown at
> http://terpconnect.umd.edu/~zhangx/imagej/nanoscopeiiireader/Picture-2
> .png
>
> Has anybody any idea how to make the TextPanel take the whole width of
> the window?
>
> Thanks in advance.
>
> Xin
>
> --
> ***********************************************
> Xin Zhang
> Graduate Student
> Department of Materials Science and Engineering University of Maryland
> at College Park
> Tel: (301)405-0900
> Email: [hidden email], [hidden email]
> Web:http://www.glue.umd.edu/~zhangx/
> ***********************************************
>



--
***********************************************
Xin Zhang
Graduate Student
Department of Materials Science and Engineering University of Maryland at
College Park
Tel: (301)405-0900
Email: [hidden email], [hidden email]
Web:http://www.glue.umd.edu/~zhangx/
***********************************************