Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31664

Re: Animations with jTextPane

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Knute Johnson <nospam@rabbitbrush.frazmtn.com>
Newsgroups comp.lang.java.programmer
Subject Re: Animations with jTextPane
Date Sun, 10 May 2015 07:49:37 -0700
Organization A noiseless patient Spider
Lines 69
Message-ID <minr3t$aua$1@dont-email.me> (permalink)
References <aabd37b8-2013-4bcb-abef-c787b5c92640@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sun, 10 May 2015 14:48:29 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="9b3fcb0d22708969e4dc99e7aa0ef1f9"; logging-data="11210"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cgbjqg+WxFDOAr+HMn5Eq"
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0
In-Reply-To <aabd37b8-2013-4bcb-abef-c787b5c92640@googlegroups.com>
Cancel-Lock sha1:tGSKDGUeT9vheD0YR614Hkr8GKE=
Xref csiph.com comp.lang.java.programmer:31664

Show key headers only | View raw


On 5/10/2015 02:57, H.L@operamail.com wrote:
>
>   Hey
>
>   We are using OpenCV to grab images from the web cam. The idea is to show the feed in a jTextPane when the user selects to show feed, otherwise other stuff can be shown in the pane. This pane is in a JFrame with  lots of other swing objects.
>
>   Basic functionality:
>
>   IplImage grabbedImage = opencv_highgui.cvQueryFrame(capture);
>    while  ((grabbedImage = opencv_highgui.cvQueryFrame(capture)) !=null)
>   	 jTextPane1.insertIcon(new ImageIcon(grabbedImage.getBufferedImage()));
>
>
> Now, we get problems because this shows multiple video frames. Obviously, it keeps inserting a new image, so they will be placed on top of each other.
>
>   We tried to clear the pane and then repaint by doing like this instead:
>
>    this.removeIcon();
>                 jTextPane1.repaint();
> 	 jTextPane1.insertIcon(new ImageIcon(grabbedImage.getBufferedImage()));
>
>   Where removeIcon looks as can be seen below:
>
>   But now, it gets flashy, the user can clearly see how the pane is cleared and then repainted, just a flashy slow change of images.
>
>   So is there any way to get around both of these issues?
>
>
>
>
>
>
>
>
>   private void removeIcon()
>    {
>      for (int i=0; i<jTextpane1.getStyledDocument().getLength(); i++)
>      {
>        Element element =
>                 jTextPane1.getStyledDocument().getCharacterElement(i);
>        AttributeSet attributeSet = element.getAttributes();
>        Icon icon = StyleConstants.getIcon(attributeSet);
>        if (icon != null)
>        {
>          try
>          {
>
>            jTextPane1.getStyledDocument().remove(i, 1);
>            jTextPane1pane.getStyledDocument().insertString(i, " ", new
>                SimpleAttributeSet());
>            icon = null;
>          }
>          catch (Exception exc)
>          {
>            System.out.println("Exception : " + exc.getMessage());
>          }
>        }
>      }
>    }
>
>
>

Have you tried just putting the image in a StyledDocument and using 
setDocument()?

-- 

Knute Johnson

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Animations with jTextPane H.L@operamail.com - 2015-05-10 02:57 -0700
  Re: Animations with jTextPane Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-05-10 07:49 -0700
    Re: Animations with jTextPane H.L@operamail.com - 2015-05-10 08:08 -0700
      Re: Animations with jTextPane Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-05-10 08:54 -0700
      Re: Animations with jTextPane Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-05-10 10:28 -0700
        Re: Animations with jTextPane H.L@operamail.com - 2015-05-10 13:28 -0700
          Re: Animations with jTextPane Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2015-05-10 14:17 -0700

csiph-web