1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
protected void paintComponent(Graphics g) {
super.paintComponent(g);
/*change la transparence ) chaque paintComponent*/
updateHightLight();
g.setColor(new Color(255,255,255, _transparenceQuiChange));
/*récupère le carré qui correspond au composant à hightlight*/
Rectangle rec2 = getDrawRectangle( _hightLightJComponent );
/*affiche le carré qui clignote*/
g.fillRect(rec2.x,rec2.y,rec2.width,rec2.height);
/**pour détecter la ou est le composent à l"écran*/
public Rectangle getDrawRectangle( JComponent jc )
{
if ( jc == null)
return new Rectangle();
Rectangle rec = new Rectangle();
Point p = new Point();
SwingUtilities.convertPointToScreen(p,jc);
Window w = SwingUtilities.windowForComponent(jc);
rec.x = p.x-jc.getRootPane().getX()-w.getLocationOnScreen().x;
rec.y = p.y-jc.getRootPane().getY()-w.getLocationOnScreen().y;
rec.width = jc.getWidth();
rec.height = jc.getHeight();
return rec;
} |
Partager