En général avec les fonts, on peut cumuler certains style comme ceci :
Font font = new Font("Tahoma", Font.BOLD|Font.ITALIC, 11);
Mais la propriété LAYOUT_RIGHT_TO_LEFT ne fait pas partie des styles il me semble.
Pour cela je pense (en me trompant peut être) qu'il faut jouer dans le paint du composant et user de GlyphVector, un peu comme ceci :
1 2 3 4 5 6 7 8
| Graphics2D g2d = (Graphics2D) g;
FontRenderContext ctxt = g2d.getFontRenderContext();
GlyphVector glyphVector = font.layoutGlyphVector(ctxt, "Salut mon ami".toCharArray(), 0, 10, Font.LAYOUT_RIGHT_TO_LEFT);
Rectangle2D logicalBounds=glyphVector.getLogicalBounds();
float tx=(float)(logicalBounds.getX() - 0.5 * logicalBounds.getWidth());
float ty=(float)(8 + logicalBounds.getHeight() + 1.0);
Shape labelOutline=glyphVector.getOutline(tx,ty);
g2d.fill(labelOutline); |
Mais je doute que ce code soit bon... mais peut être pour un début.
Partager