From e1e5d7f5c12b2480bd23a5a3eb527c6aa7de99dd Mon Sep 17 00:00:00 2001 From: La Programmatrice Verde Date: Thu, 22 Jan 2026 11:11:18 +0100 Subject: [PATCH] Aggiunto nuovo JFrame --- src/guiesempio1/GUIEsempio1.java | 70 ----------------------------- src/guiesempio1/PrimoEsempio.form | 35 +++++++++++++++ src/guiesempio1/PrimoEsempio.java | 74 +++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 70 deletions(-) delete mode 100644 src/guiesempio1/GUIEsempio1.java create mode 100644 src/guiesempio1/PrimoEsempio.form create mode 100644 src/guiesempio1/PrimoEsempio.java diff --git a/src/guiesempio1/GUIEsempio1.java b/src/guiesempio1/GUIEsempio1.java deleted file mode 100644 index 202145c..0000000 --- a/src/guiesempio1/GUIEsempio1.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template - */ -package guiesempio1; - -import java.util.InputMismatchException; -import java.util.Scanner; - -/** - * - * @author Verde - */ -public class GUIEsempio1 { - - /** - * @param args the command line arguments - */ - - static Scanner sc = new Scanner(System.in); - static final String ERRORE_GENERICO = "Errore: opzione non valida."; - - public static void main(String[] args) { - int scelta = -1; - - do { - System.out.println("Scegliere un'opzione:"); - System.out.println("1. "); - System.out.println("2. "); - System.out.println("3. "); - System.out.println("0. Esci"); - System.out.print("Opzione: "); - - try { - scelta = sc.nextInt(); - sc.nextLine(); - - switch (scelta) { - case 0: - break; - case 1: - - pausa(); - break; - case 2: - - pausa(); - break; - case 3: - - pausa(); - break; - default: - System.out.println(ERRORE_GENERICO); - pausa(); - break; - } - } - catch (InputMismatchException _) { - System.out.println(ERRORE_GENERICO); - pausa(); - } - } while (scelta != 0); - } - - public static void pausa() { - System.out.println("Premere un tasto per continuare. . ."); - sc.nextLine(); - } -} diff --git a/src/guiesempio1/PrimoEsempio.form b/src/guiesempio1/PrimoEsempio.form new file mode 100644 index 0000000..b606cd5 --- /dev/null +++ b/src/guiesempio1/PrimoEsempio.form @@ -0,0 +1,35 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/guiesempio1/PrimoEsempio.java b/src/guiesempio1/PrimoEsempio.java new file mode 100644 index 0000000..25cdb99 --- /dev/null +++ b/src/guiesempio1/PrimoEsempio.java @@ -0,0 +1,74 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package guiesempio1; + +/** + * + * @author Verde + */ +public class PrimoEsempio extends javax.swing.JFrame { + + private static final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(PrimoEsempio.class.getName()); + + /** + * Creates new form PrimoEsempio + */ + public PrimoEsempio() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 400, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 300, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ReflectiveOperationException | javax.swing.UnsupportedLookAndFeelException ex) { + logger.log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(() -> new PrimoEsempio().setVisible(true)); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables +}