GlassPane qui ne recouvre pas tous les composants ?
J'ai un soucis avec mon glassPane.
J'ai donc fait un glassPane qui sert uniquement à faire des transition entre mes onglets donc je ne l'affiche pas dès le début, ou plutôt je l'affiche mais transparent.
quand je change d'onglet je l'affiche progressivement puis le fait disparaître pour faire une petite animation.
Bref, tout ça ça fonctionne bien.
Mon glassPane ne recouvre pas toute la surface de la fenêtre. Il laisse apparaître la barre des onglets.
J'ai remarqué pendant mes animations qu'il y avait des clignotements, j'utilise le même glassPane pour une autre fenêtre mais il recouvre toute la surface et tout va bien.
Tout ces explications pas très claires pour un problème:
glassPane transparent : OK
http://www.ftpix.fr/sentpix/glassPan...8970304338.png
GlassPane affiché: Pas Ok
http://www.ftpix.fr/sentpix/glassPan...8970845499.png
en orange c'est la zone où est sensée s'afficher le glassPane.
Le code de mon glassPane:
Code:
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| public class FadePanel extends JComponent {
private float trans = 0.0f;
private int h = 0;
private int w = 0;
public FadePanel() {
setBackground(new Color(238, 238, 238));
}
public FadePanel(int w, int h) {
this.h = h;
this.w = w;
setBackground(new Color(238, 238, 238));
}
public void fadeIn() {
try {
float f = 1.0f;
while (f > 0.1f) {
trans = f;
f -= 0.2f;
repaint();
Thread.sleep(20);
}
trans = 0.0f;
repaint();
} catch (InterruptedException ex) {
Logger.getLogger(FadePanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void fadeOut() {
try {
float f = 0.0f;
while (f < 0.9f) {
trans = f;
f += 0.2f;
repaint();
Thread.sleep(20);
}
trans = 1.0f;
repaint();
} catch (InterruptedException ex) {
Logger.getLogger(FadePanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
Rectangle clip = g.getClipBounds();
// sets a 65% translucent composite
AlphaComposite alpha = AlphaComposite.SrcOver.derive(trans);
g2.setComposite(alpha);
// fills the background
g2.setColor(getBackground());
g2.fillRect(clip.x + w, clip.y + h, clip.width - w, clip.height - h);
}
} |
Merci d'avance, je bloque la :(