Deladier
asked on
take off blinking while dragging an image ??
Hi experts, I'd like to know how to take off the blinking while dragging an image? (for JDK 1.0.2)
Thank you.
Thank you.
How is the dragging being done?
ASKER
Sorry. Dragging way is:
public boolean mouseDrag(Event ev, int x, int y) {
if(over == 1) { //over an image
x = x - 8; //center image
y = y - 6; //center image
ima.setElementAt((new Integer(x)), (which+6));
ima.setElementAt((new Integer(y)), (which+7));
repaint();
}
for(int z=0; z<=((ima.size())-8); z=z+8) { //for1
dy = Integer.valueOf(ima.elemen tAt(z+7).t oString()) .intValue( );
if(y>=dy & y<=(dy+12) & y!=dy & (ima.elementAt(z+2).toStri ng()) != "I") {
which2 = z;
moveOver = 1;
}
} //for1
return true;
}
In 'if' loop I know that I already pressed over an image (over = 1 from mouseDown) and not over nothing.
'ima' is a Vector with images and the respective coordinates.
Do you think 'for' loop is the problem?. This 'for' loop is used in order to recognize over what image is dragging the image
public boolean mouseDrag(Event ev, int x, int y) {
if(over == 1) { //over an image
x = x - 8; //center image
y = y - 6; //center image
ima.setElementAt((new Integer(x)), (which+6));
ima.setElementAt((new Integer(y)), (which+7));
repaint();
}
for(int z=0; z<=((ima.size())-8); z=z+8) { //for1
dy = Integer.valueOf(ima.elemen
if(y>=dy & y<=(dy+12) & y!=dy & (ima.elementAt(z+2).toStri
which2 = z;
moveOver = 1;
}
} //for1
return true;
}
In 'if' loop I know that I already pressed over an image (over = 1 from mouseDown) and not over nothing.
'ima' is a Vector with images and the respective coordinates.
Do you think 'for' loop is the problem?. This 'for' loop is used in order to recognize over what image is dragging the image
No, I don't think so. I'm more concerned with the paint method. Could you post that as well? Have you overridden the update method (which clears the screen before paint is called (which will cause a flicker)?
ASKER
You're right, I haven't used update method, where do I put it?.
Here's the paint method:
public void paint(Graphics g) {
g.drawImage(getImage(getDo cumentBase (), "menutree/w_raiz.gif"), 12, 0, this);
Font raizfuen = new Font("Courier", Font.PLAIN, 10);
g.setFont(raizfuen);
g.setColor(Color.blue);
g.drawString("Root", 30, 11);
g.drawImage(getImage(getDo cumentBase (), "menutree/w_raiz.gif"), 65, 0, this);
Font borrafuen = new Font("Courier", Font.PLAIN, 10);
g.setFont(borrafuen);
g.setColor(Color.red);
g.drawString("Erase Element", 83, 11);
for(int u=0; u<=((ima.size())-8); u=u+8) { //forqw
if((ima.elementAt(u).toStr ing()) == "F" &
(ima.elementAt(u+1).toStri ng()) == "C" &
(ima.elementAt(u+2).toStri ng()) == "V") { //iffc
String nomfold = ima.elementAt(u+5).toStrin g();
g.drawImage(getImage(getDo cumentBase (), "menutree/wcf.gif"),
(Integer.valueOf(ima.eleme ntAt(u + 6).toString()).intValue()) ,
(Integer.valueOf(ima.eleme ntAt(u + 7).toString()).intValue()) , this);
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomfold,
((Integer.valueOf(ima.elem entAt(u + 6).toString()).intValue()) + 22),
((Integer.valueOf(ima.elem entAt(u + 7).toString()).intValue()) + 10));
} //iffc
if((ima.elementAt(u).toStr ing()) == "F" &
(ima.elementAt(u+1).toStri ng()) == "A" &
(ima.elementAt(u+2).toStri ng()) == "V") { //iffa
String nomfold = ima.elementAt(u+5).toStrin g();
g.drawImage(getImage(getDo cumentBase (), "menutree/wof.gif"),
(Integer.valueOf(ima.eleme ntAt(u + 6).toString()).intValue()) ,
(Integer.valueOf(ima.eleme ntAt(u + 7).toString()).intValue()) , this);
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomfold,
((Integer.valueOf(ima.elem entAt(u + 6).toString()).intValue()) + 22),
((Integer.valueOf(ima.elem entAt(u + 7).toString()).intValue()) + 10));
} //iffa
if((ima.elementAt(u).toStr ing()) == "B" &
(ima.elementAt(u+2).toStri ng()) == "V") { //aq
String nomdoc = ima.elementAt(u+5).toStrin g();
g.drawImage(getImage(getDo cumentBase (), "menutree/wdoc.gif"),
(Integer.valueOf(ima.eleme ntAt(u + 6).toString()).intValue()) ,
(Integer.valueOf(ima.eleme ntAt(u + 7).toString()).intValue()) , this);
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomdoc,
((Integer.valueOf(ima.elem entAt(u + 6).toString()).intValue()) + 22),
((Integer.valueOf(ima.elem entAt(u + 7).toString()).intValue()) + 10));
} //aq
} //forqw
if(moveOver == 1 & (ima.elementAt(which2).toS tring()) == "B" &
(ima.elementAt(which2+2).t oString()) != "I") { //zx
String nomdoc = ima.elementAt(which2+5).to String();
g.drawImage(getImage(getDo cumentBase (), "menutree/ddoc.gif"),
(Integer.valueOf(ima.eleme ntAt(which 2 + 6).toString()).intValue()) ,
(Integer.valueOf(ima.eleme ntAt(which 2 + 7).toString()).intValue()) , this);
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomdoc,
((Integer.valueOf(ima.elem entAt(whic h2 + 6).toString()).intValue()) + 22),
((Integer.valueOf(ima.elem entAt(whic h2 + 7).toString()).intValue()) + 10));
} //zx
if(moveOver == 1 & (ima.elementAt(which2).toS tring()) == "F" &
(ima.elementAt(which2+1).t oString()) == "C") { //zx1
String nomdoc = ima.elementAt(which2+5).to String();
g.drawImage(getImage(getDo cumentBase (), "menutree/dcf.gif"),
(Integer.valueOf(ima.eleme ntAt(which 2 + 6).toString()).intValue()) ,
(Integer.valueOf(ima.eleme ntAt(which 2 + 7).toString()).intValue()) , this);
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomdoc,
((Integer.valueOf(ima.elem entAt(whic h2 + 6).toString()).intValue()) + 22),
((Integer.valueOf(ima.elem entAt(whic h2 + 7).toString()).intValue()) + 10));
} //zx1
if(moveOver == 1 & (ima.elementAt(which2).toS tring()) == "F" &
(ima.elementAt(which2+1).t oString()) == "A") { //zx2
String nomdoc = ima.elementAt(which2+5).to String();
g.drawImage(getImage(getDo cumentBase (), "menutree/dof.gif"),
(Integer.valueOf(ima.eleme ntAt(which 2 + 6).toString()).intValue()) ,
(Integer.valueOf(ima.eleme ntAt(which 2 + 7).toString()).intValue()) , this);
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomdoc,
((Integer.valueOf(ima.elem entAt(whic h2 + 6).toString()).intValue()) + 22),
((Integer.valueOf(ima.elem entAt(whic h2 + 7).toString()).intValue()) + 10));
} //zx2
}
Here's the paint method:
public void paint(Graphics g) {
g.drawImage(getImage(getDo
Font raizfuen = new Font("Courier", Font.PLAIN, 10);
g.setFont(raizfuen);
g.setColor(Color.blue);
g.drawString("Root", 30, 11);
g.drawImage(getImage(getDo
Font borrafuen = new Font("Courier", Font.PLAIN, 10);
g.setFont(borrafuen);
g.setColor(Color.red);
g.drawString("Erase Element", 83, 11);
for(int u=0; u<=((ima.size())-8); u=u+8) { //forqw
if((ima.elementAt(u).toStr
(ima.elementAt(u+1).toStri
(ima.elementAt(u+2).toStri
String nomfold = ima.elementAt(u+5).toStrin
g.drawImage(getImage(getDo
(Integer.valueOf(ima.eleme
(Integer.valueOf(ima.eleme
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomfold,
((Integer.valueOf(ima.elem
((Integer.valueOf(ima.elem
} //iffc
if((ima.elementAt(u).toStr
(ima.elementAt(u+1).toStri
(ima.elementAt(u+2).toStri
String nomfold = ima.elementAt(u+5).toStrin
g.drawImage(getImage(getDo
(Integer.valueOf(ima.eleme
(Integer.valueOf(ima.eleme
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomfold,
((Integer.valueOf(ima.elem
((Integer.valueOf(ima.elem
} //iffa
if((ima.elementAt(u).toStr
(ima.elementAt(u+2).toStri
String nomdoc = ima.elementAt(u+5).toStrin
g.drawImage(getImage(getDo
(Integer.valueOf(ima.eleme
(Integer.valueOf(ima.eleme
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomdoc,
((Integer.valueOf(ima.elem
((Integer.valueOf(ima.elem
} //aq
} //forqw
if(moveOver == 1 & (ima.elementAt(which2).toS
(ima.elementAt(which2+2).t
String nomdoc = ima.elementAt(which2+5).to
g.drawImage(getImage(getDo
(Integer.valueOf(ima.eleme
(Integer.valueOf(ima.eleme
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomdoc,
((Integer.valueOf(ima.elem
((Integer.valueOf(ima.elem
} //zx
if(moveOver == 1 & (ima.elementAt(which2).toS
(ima.elementAt(which2+1).t
String nomdoc = ima.elementAt(which2+5).to
g.drawImage(getImage(getDo
(Integer.valueOf(ima.eleme
(Integer.valueOf(ima.eleme
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomdoc,
((Integer.valueOf(ima.elem
((Integer.valueOf(ima.elem
} //zx1
if(moveOver == 1 & (ima.elementAt(which2).toS
(ima.elementAt(which2+1).t
String nomdoc = ima.elementAt(which2+5).to
g.drawImage(getImage(getDo
(Integer.valueOf(ima.eleme
(Integer.valueOf(ima.eleme
Font fuente = new Font("Helvetica", Font.PLAIN, 10);
g.setFont(fuente);
g.drawString(nomdoc,
((Integer.valueOf(ima.elem
((Integer.valueOf(ima.elem
} //zx2
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. :)