esempio: rosso (255,0 , 0)
Color colore = new Color(255, 0, 0);
esempio: giallo
Color.YELLOW
esempio: etichetta con sfondo giallo
JLabel etichetta = new JLabel();
etichetta.setOpaque(true);
etichetta.setBackground(Color.YELLOW);
esempio: etichetta con testo rosso
JLabel etichetta = new JLabel();
Color colore = new Color(255, 0, 0);
etichetta.setForeground(colore);
esempio:
JLabel etichetta = new JLabel();
Font testo = new Font ("Time New Roman", Font.PLAIN, 32);
etichetta.setFont(testo);
esempio
// variabili globali
JPanel pannello = new JPanel(); // pannello
JLabel etichetta = new JLabel(); // etichetta
Color colore = new Color(255, 0, 0); // colore RGB (rosso)
Font testo = new Font ("Time New Roman", Font.PLAIN, 32); // crea font
public static void main(String args[])
{
Settaggi form = new Settaggi(); // avvia il form}
super("Test etichetta"); // titolo del Form}
setSize(500,500); // dimensioni
setDefaultCloseOperation(EXIT_ON_CLOSE); // operazione da eseguire dei defaul (metti sempre questa)
setVisible(true); // visualizza
// aggiungi componenti
add(pannello); // aggiungi pannello
// settaggio
etichetta.setText("testo etichetta finale"); // modifica testo etichetta
etichetta.setFont(testo); // setta il font della etichetta
etichetta.setOpaque(true); //
etichetta.setBackground(Color.YELLOW); // sfondo giallo
etichetta.setForeground(colore); // colore font creato (rosso)
// inserire etichette
pannello.add(etichetta); // inserire etichetta