inserire un bottone nel pannello

sintassi



esempio:
// variabili globali
JPanel pannello = new JPanel();

JButton bottonetesto = new JButton("testo); bottone con testo (il testo può essere settato dopo)

ImageIcon icona = new ImageIcon("path/fileimmagine"); icona
JButton bottoneicona = new JButton(icona); bottone con icona


public static void main(String args[])
{

Nome_Form form = new Nome_Form(); // avvia il form
}


// costruttore e settaggi del Form
public Nome_Form()
{
.... // settaggi form


// aggiungi componenti
add(pannello);

pannello.add(bottonetesto); // aggiungi bottone testo
bottonetesto.setText("Bottone testo"); inseire/modifica il testo
bottonetesto.setBackground(Color.colore); colore sfondo


pannello.add(bottoneicona); // aggiungi bottone icona
}