commit 87e45c6c58ea95a39cf5894c28a4c436a336f98d Author: P Date: Sun May 11 21:18:58 2025 +0200 Commit iniziale diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..5f0ee65 --- /dev/null +++ b/Main.java @@ -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 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 nomi = new ArrayList<>(); + + for(Lavoratore lavoratore : lavoratori) { + nomi.add(lavoratore.nome + " " + lavoratore.cognome); + } + + JList 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; + } + } +}