Commit iniziale
This commit is contained in:
commit
87e45c6c58
54
Main.java
Normal file
54
Main.java
Normal file
@ -0,0 +1,54 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Lavoratore> lavoratori = new ArrayList<>();
|
||||
lavoratori.add(new Lavoratore("Marco", "Rossi"));
|
||||
lavoratori.add(new Lavoratore("Laura", "Bianchi"));
|
||||
lavoratori.add(new Lavoratore("Alessandro", "Verdi"));
|
||||
lavoratori.add(new Lavoratore("Francesco", "Esposito"));
|
||||
lavoratori.add(new Lavoratore("Luca", "Romano"));
|
||||
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
|
||||
JFrame frame = new JFrame("Ciso mondo");
|
||||
|
||||
frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.X_AXIS));
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
|
||||
List<String> nomi = new ArrayList<>();
|
||||
|
||||
for(Lavoratore lavoratore : lavoratori) {
|
||||
nomi.add(lavoratore.nome + " " + lavoratore.cognome);
|
||||
}
|
||||
|
||||
JList<String> lista = new JList<>(nomi.toArray(new String[0]));
|
||||
frame.add(lista);
|
||||
|
||||
|
||||
|
||||
frame.setSize(400, 400);
|
||||
frame.setVisible(true);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static class Lavoratore {
|
||||
public String nome;
|
||||
public String cognome;
|
||||
|
||||
public Lavoratore(String nome, String cognome) {
|
||||
this.nome = nome;
|
||||
this.cognome = cognome;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user