Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Advanced-java] JApplet is Flashing and blinking


  • From: nadia@xxxxxxxxx (Nadia Ebrahim)
  • Subject: [Advanced-java] JApplet is Flashing and blinking
  • Date: Tue, 27 Mar 2001 10:14:45 +0200

This is a multi-part message in MIME format.

--Boundary_(ID_L3SMF5i26DQCZATCo/nMmQ)
Content-type: text/plain;	charset="iso-8859-1"
Content-transfer-encoding: quoted-printable

Hi there friends
I have made a JApplet and when I load it in Internet Explorer and try to =
scroll down it.It flashes,blinks and dark black lines come over it .I =
have heard about double buffering and have tried to implement it within =
my JApplet.
I have no idea what the problem can be ......
I am displaying JLabels and a Canvas with graphics on it.
I am not sure if my paint method is maybe the problem .In my paint =
method all I do is set the Text of the labels .

 my constructer looks like the following:
public init{
try{
          image=3Dthis.createImage(size().width,size().height);
          MediaTracker mt=3Dnew MediaTracker(this);
          mt.addImage(image,0)
           mt.waitForAll();
     }catch(Exception e){}
             int iw =3D image.getWidth(this);
             int ih =3D image.getHeight(this);
            bi =3D new BufferedImage(iw, ih, =
BufferedImage.TYPE_INT_RGB);
            Graphics2D big =3D bi.createGraphics();
             big.drawImage(image,0,0,this);
 =20
}
My update class looks like this:
public void update(Graphics g)
  {=20
 Graphics2D gr=3D(Graphics2D)g;
  if(image=3D=3Dnull)
     {
       image=3Dthis.createImage(size().width,size().height);
 try{ =20
   MediaTracker mtsec=3Dnew MediaTracker(this); =20
   mtsec.addImage(image,1);  =20
   mtsec.waitForAll();
     }catch(Exception e){}
   } =20
         int iw =3D image.getWidth(this);
         int ih =3D image.getHeight(this);
        bi =3D new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
        gr =3D bi.createGraphics();
        paint(gr);    =20
        gr.drawImage(image,0,0,this);
  }
My paint method looks like this..
  public void paint(Graphics2D g)
  {
     currenttargetlabel.setText("      "+formatlabel.format(curtarget));
    gantryangle.setText(formatlabel.format(gangle));
    ratioab.setText((formatNumber.format(relab)));
    ratiocd.setText((formatNumber.format(relcd)));
    straybeamlabel.setText(formatlabel.format(straybeam)+"nA");
    firstlabel.setText(formatsome.format(firstdoub));
    secondlabel.setText(formatsome.format(seconddoub));
    secondxlabel.setText(formatsome.format(thirddoub));
    thirdlabel.setText(formatsome.format(secondx));
    paintstatus();
    paintntframe();
    paintconsole();
    paintvariable(number);=20
  }


Please help..
If you have any suggestions or comments .I am a beginner with Java and =
not sure where the problem is.
Thanking you in advance
Nadia

--Boundary_(ID_L3SMF5i26DQCZATCo/nMmQ)
Content-type: text/html;	charset="iso-8859-1"
Content-transfer-encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2014.210" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi there friends</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have made a JApplet and when I load =
it in=20
Internet Explorer and try to scroll down it.It flashes,blinks and dark =
black=20
lines&nbsp;come over it .I have heard about double buffering and have =
tried to=20
implement it within my JApplet.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have no idea what the problem can be=20
......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I am displaying JLabels and a Canvas =
with graphics=20
on it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I am not sure if my paint method is =
maybe the=20
problem .In my paint method all I do is set the Text of the labels =
.</FONT><FONT=20
face=3DArial size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;my constructer looks like the=20
following:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public init{</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>try{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
image=3Dthis.createImage(size().width,size().height);<BR>&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; MediaTracker mt=3Dnew=20
MediaTracker(this);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =

mt.addImage(image,0)</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;mt.waitForAll();<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
}catch(Exception e){}</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; int iw =3D=20
image.getWidth(this);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
int ih =3D image.getHeight(this);<BR>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; bi =3D new BufferedImage(iw, ih,=20
BufferedImage.TYPE_INT_RGB);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
Graphics2D big =3D=20
bi.createGraphics();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;big.drawImage(image,0,0,this);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>My update class looks like =
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public void update(Graphics =
g)<BR>&nbsp;=20
{&nbsp;<BR>&nbsp;Graphics2D gr=3D(Graphics2D)g;<BR>&nbsp;=20
if(image=3D=3Dnull)<BR>&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
image=3Dthis.createImage(size().width,size().height);<BR>&nbsp;try{&nbsp;=
&nbsp;<BR>&nbsp;&nbsp;&nbsp;MediaTracker=20
mtsec=3Dnew=20
MediaTracker(this);&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;mtsec.addImage(image=
,1);&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;mtsec.waitForAll();<BR>&nbsp;=
&nbsp;&nbsp;&nbsp;=20
}catch(Exception e){}<BR>&nbsp;&nbsp; }&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iw =3D=20
image.getWidth(this);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;int=20
ih =3D image.getHeight(this);<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
bi =3D new=20
BufferedImage(iw, ih,=20
BufferedImage.TYPE_INT_RGB);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;gr=20
=3D=20
bi.createGraphics();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p=
aint(gr);&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;gr.drawImage(image,0,0,this);<BR>&nbsp; }</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>My paint method looks like =
this..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; public void paint(Graphics2D =
g)<BR>&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;=20
currenttargetlabel.setText("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
"+formatlabel.format(curtarget));<BR>&nbsp;&nbsp;&nbsp;=20
gantryangle.setText(formatlabel.format(gangle));<BR>&nbsp;&nbsp;&nbsp;=20
ratioab.setText((formatNumber.format(relab)));<BR>&nbsp;&nbsp;&nbsp;=20
ratiocd.setText((formatNumber.format(relcd)));<BR>&nbsp;&nbsp;&nbsp;=20
straybeamlabel.setText(formatlabel.format(straybeam)+"nA");<BR>&nbsp;&nbs=
p;&nbsp;=20
firstlabel.setText(formatsome.format(firstdoub));<BR>&nbsp;&nbsp;&nbsp;=20
secondlabel.setText(formatsome.format(seconddoub));<BR>&nbsp;&nbsp;&nbsp;=
=20
secondxlabel.setText(formatsome.format(thirddoub));<BR>&nbsp;&nbsp;&nbsp;=
=20
thirdlabel.setText(formatsome.format(secondx));<BR>&nbsp;&nbsp;&nbsp;=20
paintstatus();<BR>&nbsp;&nbsp;&nbsp; =
paintntframe();<BR>&nbsp;&nbsp;&nbsp;=20
paintconsole();<BR>&nbsp;&nbsp;&nbsp; =
paintvariable(number);&nbsp;<BR>&nbsp;=20
}<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Please help..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>If you have any suggestions or comments =
.I=20
am&nbsp;a beginner with Java and not sure where the problem =
is.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanking you in advance</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Nadia</DIV></FONT></BODY></HTML>

--Boundary_(ID_L3SMF5i26DQCZATCo/nMmQ)--