Alignement vertical d'un JPanel
Salut,
Je réalise un compteur avec des secondes et des milli-secondes. Et je souhaite afficher les milli-secondes en plus petit. Mais le JLabel contenant les milli-secondes est centré et je veux le positionner en bas.
Voici ce qui est affiché :
http://img528.imageshack.us/img528/9822/chronogo4.png
Et voici le code :
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
| import java.awt.Font;
import javax.swing.*;
import javax.swing.border.EtchedBorder;
public class Chronos extends JPanel {
public Chronos () {
super ();
setLayout (new BoxLayout (this, BoxLayout.X_AXIS));
setAlignmentY (BOTTOM_ALIGNMENT);
setBorder (new EtchedBorder ());
m_seconds = new JLabel ("06");
m_seconds.setFont (new Font ("Verdana", Font.BOLD, 80));
m_seconds.setVerticalAlignment (SwingConstants.BOTTOM);
add (m_seconds);
final JLabel point = new JLabel (".");
point.setVerticalAlignment (SwingConstants.BOTTOM);
point.setFont (new Font ("Verdana", Font.BOLD, 20));
add (point);
m_millis = new JLabel ("736");
m_millis.setFont (new Font ("Verdana", Font.BOLD, 20));
m_millis.setVerticalAlignment (SwingConstants.BOTTOM);
add (m_millis);
} // Chronos ()
private JLabel m_seconds;
private JLabel m_millis;
} // Chronos |
J'ai pourtant défini l'alignement : setAlignmentY (BOTTOM_ALIGNMENT);
Ai-je fait une erreur ou y a-t-il un solution simple ?
Merci d'avance,
regseb.