Re: Animations with jTextPane

Posted by H L a... on 10. May 2015

Thank you for helping me with this. We have not tried this, but please not=
e that we are continouusly changing what image is shown. The web cam captur=
es a new image and this is shown on the screen, how could we do this updati=
ng with setDocument()?



Den s=F8ndag den 10. maj 2015 kl. 16.49.42 UTC+2 skrev Knute Johnson:




On 5/10/2015 02:57, [email protected] wrote:




Hey



We are using OpenCV to grab images from the web cam. The idea is to s=
how the feed in a jTextPane when the user selects to show feed, otherwise o=
ther stuff can be shown in the pane. This pane is in a JFrame with lots of=
other swing objects.



Basic functionality:



IplImage grabbedImage =3D opencvhighgui.cvQueryFrame(capture);
while ((grabbedImage =3D opencv
highgui.cvQueryFrame(capture)) !=3D=
null)
jTextPane1.insertIcon(new ImageIcon(grabbedImage.getBufferedImage()=
));



Now, we get problems because this shows multiple video frames. Obviousl=
y, it keeps inserting a new image, so they will be placed on top of each ot=
her.



We tried to clear the pane and then repaint by doing like this instea=
d:



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 cle=
ared 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=3D0; i<jTextpane1.getStyledDocument().getLength(); i++)
{
Element element =3D
jTextPane1.getStyledDocument().getCharacterElement(i);
AttributeSet attributeSet =3D element.getAttributes();
Icon icon =3D StyleConstants.getIcon(attributeSet);
if (icon !=3D null)
{
try
{



       jTextPane1.getStyledDocument().remove(i, 1);
jTextPane1pane.getStyledDocument().insertString(i, " ", new
SimpleAttributeSet());
icon =3D null;
}
catch (Exception exc)
{
System.out.println("Exception : " + exc.getMessage());
}
}
}


}



=20
Have you tried just putting the image in a StyledDocument and using=20
setDocument()?
=20
--=20
=20
Knute Johnson




07. Apr 2015: Re: Return of the Applets? by Silvi...

07. Apr 2015: Re: Return of the Applets? by Jerry...

07. Apr 2015: Re: Return of the Applets? by Jerry...

07. Apr 2015: Re: Return of the Applets? by Jerry...

07. Apr 2015: Re: Return of the Applets? by Jerry...

07. Apr 2015: Re: Return of the Applets? by ram a...

07. Apr 2015: Re: Return of the Applets? by Marti...

07. Apr 2015: Re: Return of the Applets? by Marti...

07. Apr 2015: Re: Return of the Applets? by Jerry...

07. Apr 2015: Re: Return of the Applets? by Jerry...

07. Apr 2015: Re: Return of the Applets? by Leif ...

07. Apr 2015: Re: Return of the Applets? by Leif ...

07. Apr 2015: Re: Return of the Applets? by Jerry...

07. Apr 2015: Re: presentable Java features and programs by Jeff ...

07. Apr 2015: Re: Return of the Applets? by Jerry...

06. Apr 2015: Re: Return of the Applets? by Marti...

06. Apr 2015: presentable Java features and programs by ram a...

06. Apr 2015: Re: Return of the Applets? by Joshu...

06. Apr 2015: Re: presentable Java features and programs by Eric ...

06. Apr 2015: Re: Return of the Applets? by Kevin...

06. Apr 2015: Re: presentable Java features and programs by Arne ...

06. Apr 2015: Re: presentable Java features and programs by Jeff ...

06. Apr 2015: Re: presentable Java features and programs by Arne ...

06. Apr 2015: Re: presentable Java features and programs by Jeff ...

06. Apr 2015: Re: presentable Java features and programs by Eric ...

06. Apr 2015: Re: presentable Java features and programs by Jeff ...

06. Apr 2015: Re: Return of the Applets? by Jerry...

06. Apr 2015: Re: Return of the Applets? by Jerry...

06. Apr 2015: Re: presentable Java features and programs by Jerry...

06. Apr 2015: Re: Return of the Applets? by Joshu...

06. Apr 2015: Re: Return of the Applets? by Jerry...

06. Apr 2015: Re: Return of the Applets? by Joshu...

06. Apr 2015: Re: Return of the Applets? by Jan B...

06. Apr 2015: Re: Return of the Applets? by Jan B...

06. Apr 2015: Re: Return of the Applets? by Jan B...

06. Apr 2015: Re: Return of the Applets? by Jerry...

06. Apr 2015: Re: Any good book/website with samples how to run Java in web applications? by Marti...

06. Apr 2015: Re: Return of the Applets? by Joshu...

06. Apr 2015: Re: Return of the Applets? by Joshu...

06. Apr 2015: Re: Return of the Applets? by Luuk ...

06. Apr 2015: Re: Return of the Applets? by Richa...

06. Apr 2015: Re: Return of the Applets? by Jeff ...

06. Apr 2015: Re: Return of the Applets? by Jeff ...

06. Apr 2015: Re: What are the professional development kits for Java by david...

05. Apr 2015: Re: Return of the Applets? by Arne ...

05. Apr 2015: Re: Return of the Applets? by Arne ...

05. Apr 2015: Re: Any good book/website with samples how to run Java in web applications? by Arne ...

05. Apr 2015: Re: Return of the Applets? by Jerry...

05. Apr 2015: Re: Return of the Applets? by Arne ...

05. Apr 2015: Re: Return of the Applets? by Jerry...

05. Apr 2015: Re: Return of the Applets? by ram a...

05. Apr 2015: Re: Return of the Applets? by Arne ...

05. Apr 2015: Re: Any good book/website with samples how to run Java in web applications? by Arne ...

05. Apr 2015: Re: Return of the Applets? by Jerry...

05. Apr 2015: Re: Return of the Applets? by Arne ...

05. Apr 2015: Re: Return of the Applets? by Jerry...

05. Apr 2015: Re: Return of the Applets? by Arne ...

05. Apr 2015: Re: Any good book/website with samples how to run Java in web applications? by dffdf...

05. Apr 2015: Re: Return of the Applets? by Jerry...

05. Apr 2015: Re: Integer.parseInt() and whitespace? by Jukka...

05. Apr 2015: Re: Any good book/website with samples how to run Java in web applications? by dffdf...

05. Apr 2015: Re: Any good book/website with samples how to run Java in web applications? by Arne ...

05. Apr 2015: Re: Integer.parseInt() and whitespace? by Arne ...

05. Apr 2015: Re: Return of the Applets? by Jeff ...

05. Apr 2015: Re: What are the professional development kits for Java by Arne ...

05. Apr 2015: Re: Return of the Applets? by Jerry...

05. Apr 2015: Return of the Applets? by ram a...

05. Apr 2015: Re: Integer.parseInt() and whitespace? by ram a...

04. Apr 2015: Any good book/website with samples how to run Java in web applications? by dffdf...

04. Apr 2015: Re: What are the professional development kits for Java by Arne ...

04. Apr 2015: Integer.parseInt() and whitespace? by galt_...

04. Apr 2015: What are the professional development kits for Java by dffdf...

04. Apr 2015: Re: Client and ... ? by Jeff ...

04. Apr 2015: Muhammad's Sword by BV BV...

04. Apr 2015: Re: how to write this simple program? by Lew l...

04. Apr 2015: Re: Client and ... ? by Lew l...

03. Apr 2015: Re: Simple if-exercises by v_bor...

03. Apr 2015: Re: Simple if-exercises by Marti...

03. Apr 2015: Re: Simple if-exercises by Jeff ...

03. Apr 2015: Re: Simple if-exercises by Marti...

03. Apr 2015: Re: Simple if-exercises by v_bor...

03. Apr 2015: Re: Simple if-exercises by Eric ...

03. Apr 2015: Re: Simple if-exercises by Marti...

03. Apr 2015: Re: Simple if-exercises by Eric ...

03. Apr 2015: Re: Simple if-exercises by v_bor...

03. Apr 2015: Get Access to the Professional Videos of Java at ITeLearn by charl...

02. Apr 2015: Re: Simple if-exercises by Gene ...

02. Apr 2015: Re: Simple if-exercises by Jerry...

02. Apr 2015: Re: Simple if-exercises by Marti...

02. Apr 2015: Re: Simple if-exercises by Jeff ...

02. Apr 2015: Re: Simple if-exercises by Jeff ...

02. Apr 2015: Re: Simple if-exercises by Eric ...

02. Apr 2015: Simple if-exercises by ram a...

01. Apr 2015: Re: .parallelStream() by Sebas...

01. Apr 2015: .parallelStream() by ram a...

01. Apr 2015: Client and ... ? by ram a...

01. Apr 2015: Re: Is it legal to backport code from JDK8 to JDK6? by Haddo...

01. Apr 2015: Re: .parallelStream() by Eric ...

01. Apr 2015: Re: Client and ... ? by Jeff ...

31. Mar 2015: Re: Is it legal to backport code from JDK8 to JDK6? by Sebas...