import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingConstants; import java.awt.Font; public class FCJLabel extends JFrame { public FCJLabel() { setSize( 275, 180 ); setLayout( new FlowLayout() ); JLabel myLabel = new JLabel(); // Modifier la couleur de texte myLabel.setText("<html><body><font color='blue'>Exemple JLabel texte coloré:</body></html>" ); myLabel.setToolTipText( myLabel.getText() ); add( myLabel ); } public static void main (String[] args) { JFrame frameLabel=new FCJLabel(); frameLabel.setTitle("Attributs des JLabels"); frameLabel.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frameLabel.setVisible(true); } } |