From 7167b4341ef290d56fb96e2af10883a4b925d83b Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 26 Mar 2026 19:27:18 +0100 Subject: I found my old code! --- .../v2.3/src/RobottinoUtils/Grafica.java | 210 +++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100755 robottino/all_versions/v2.3/src/RobottinoUtils/Grafica.java (limited to 'robottino/all_versions/v2.3/src/RobottinoUtils/Grafica.java') diff --git a/robottino/all_versions/v2.3/src/RobottinoUtils/Grafica.java b/robottino/all_versions/v2.3/src/RobottinoUtils/Grafica.java new file mode 100755 index 0000000..b845a7f --- /dev/null +++ b/robottino/all_versions/v2.3/src/RobottinoUtils/Grafica.java @@ -0,0 +1,210 @@ +// Dichiaro che questa classa farà parte del package RobottinoUtils, che verrà poi importato dalla classe Robottino. +package RobottinoUtils; + +// Importo i package standard relativi al funzionamento delle finestre e della grafica in generale. +import java.awt.*; + +// E i package RobottinoAzioni e RobottinoUtils da me definiti. +import RobottinoAzioni.*; +import RobottinoUtils.Listener; + +// La classe è una sottoclasse di Frame per poter sfruttare gli effetti grafici +// ma implementa anche l'interfaccia WindowListener, necessaria per gestire gli eventi collegati alle finestre +// (riduzione a icona, chiusura...); per questo devo successivamente ridefinire tutti i +// metodi dell'interfaccia. +public class Grafica extends Frame { + + // Creo un'istanza della classe Listener che userò come listener per gli eventi. + public static Listener listener; + + // Il costruttore senza argomenti. + public Grafica () { + + // Il metodo "setBounds" posiziona e dimensiona la finestra. + setBounds (this.orizzontale, this.verticale, this.larghezza, this.altezza); + + // "setTitle" per il titolo della finestra. + setTitle ("Robottino v2.2"); + + // "setVisible" per poterla visualizzare. + setVisible (true); + + // E addWindowListener per l'ascoltatore (listener). + listener = new Listener(); + addWindowListener (listener); + + // Aggiungo la barra del menu con i vari sottomenu + setMenuBar (barraMenu); + + // Il menu file. + NewRobot.addActionListener(listener); + NewRobot.setActionCommand("newrobot"); + + ChangeRobot.addActionListener(listener); + ChangeRobot.setActionCommand("changerobot"); + + DeleteRobot.addActionListener(listener); + DeleteRobot.setActionCommand("deleterobot"); + + Exit.addActionListener(listener); + Exit.setActionCommand("exit"); + + file.add(NewRobot); + file.add(ChangeRobot); + file.add(DeleteRobot); + file.addSeparator(); + file.add(Exit); + + barraMenu.add(file); + + // Il braccio sinistro. + LeftArmMove.addActionListener(listener); + LeftArmMove.setActionCommand("leftarmmove"); + + LeftArmOn.addActionListener(listener); + LeftArmOn.setActionCommand("leftarmon"); + + LeftArmOff.addActionListener(listener); + LeftArmOff.setActionCommand("leftarmoff"); + + LeftArm.add(LeftArmMove); + LeftArm.add(LeftArmOn); + LeftArm.add(LeftArmOff); + + // Il braccio destro. + RightArmMove.addActionListener(listener); + RightArmMove.setActionCommand("rightarmmove"); + + RightArmOn.addActionListener(listener); + RightArmOn.setActionCommand("rightarmon"); + + RightArmOff.addActionListener(listener); + RightArmOff.setActionCommand("rightarmoff"); + + RightArm.add(RightArmMove); + RightArm.add(RightArmOn); + RightArm.add(RightArmOff); + + // La gamba sinistra. + LeftLegMove.addActionListener(listener); + LeftLegMove.setActionCommand("leftlegmove"); + + LeftLegOn.addActionListener(listener); + LeftLegOn.setActionCommand("leftlegon"); + + LeftLegOff.addActionListener(listener); + LeftLegOff.setActionCommand("leftlegoff"); + + LeftLeg.add(LeftLegMove); + LeftLeg.add(LeftLegOn); + LeftLeg.add(LeftLegOff); + + // La gamba destra. + RightLegMove.addActionListener(listener); + RightLegMove.setActionCommand("rightlegmove"); + + RightLegOn.addActionListener(listener); + RightLegOn.setActionCommand("rightlegon"); + + RightLegOff.addActionListener(listener); + RightLegOff.setActionCommand("rightlegoff"); + + RightLeg.add(RightLegMove); + RightLeg.add(RightLegOn); + RightLeg.add(RightLegOff); + + // Menu rinomina. + Rename.addActionListener(listener); + Rename.setActionCommand("rename"); + + Menu modifica = new Menu("Modifica"); + modifica.add(LeftArm); + modifica.add(RightArm); + modifica.add(LeftLeg); + modifica.add(RightLeg); + modifica.addSeparator(); + modifica.add(Rename); + + barraMenu.add(modifica); + + // Menu azioni. + Exploud.addActionListener(listener); + Exploud.setActionCommand("exploud"); + + Bier.addActionListener(listener); + Bier.setActionCommand("bier"); + + xxx.addActionListener(listener); + xxx.setActionCommand("xxx"); + + Dance.addActionListener(listener); + Dance.setActionCommand("dance"); + + azioni.add(Exploud); + azioni.add(Bier); + azioni.add(xxx); + azioni.add(Dance); + + barraMenu.add(azioni); + + // Menu info. + Porky.addActionListener(listener); + Porky.setActionCommand("porky"); + + l.addActionListener(listener); + l.setActionCommand("l"); + + RobotList.addActionListener(listener); + RobotList.setActionCommand("robotlist"); + + info.add(Porky); + info.add(l); + info.add(RobotList); + + barraMenu.add(info); + } + + // Le variabili pubbliche di classe per il metodo "setBounds". + public int orizzontale = 0; + public int verticale = 0; + public int larghezza = 500; + public int altezza = 500; + + // E i vari Menu e MenuItem. + MenuBar barraMenu = new MenuBar(); + Menu file = new Menu("File"); + MenuItem NewRobot = new MenuItem("Nuovo robot"); + MenuItem ChangeRobot = new MenuItem("Dai i comandi a un altro robot"); + MenuItem DeleteRobot = new MenuItem("Elimina un robot"); + MenuItem Exit = new MenuItem("Esci"); + Menu LeftArm = new Menu("Braccio sinistro"); + MenuItem LeftArmMove = new MenuItem("Cambia posizione"); + MenuItem LeftArmOn = new MenuItem("Alza"); + MenuItem LeftArmOff = new MenuItem("Abbassa"); + Menu RightArm = new Menu("Braccio destro"); + MenuItem RightArmMove = new MenuItem("Cambia posizione"); + MenuItem RightArmOn = new MenuItem("Alza"); + MenuItem RightArmOff = new MenuItem("Abbassa"); + Menu LeftLeg = new Menu("Gamba sinistra"); + MenuItem LeftLegMove = new MenuItem("Cambia posizione"); + MenuItem LeftLegOn = new MenuItem("Alza"); + MenuItem LeftLegOff = new MenuItem("Abbassa"); + Menu RightLeg = new Menu("Gamba destra"); + MenuItem RightLegMove = new MenuItem("Cambia posizione"); + MenuItem RightLegOn = new MenuItem("Alza"); + MenuItem RightLegOff = new MenuItem("Abbassa"); + MenuItem Rename = new MenuItem("Rinomina"); + Menu azioni = new Menu("Azioni"); + MenuItem Exploud = new MenuItem("Esplodi"); + MenuItem Bier = new MenuItem("Birra"); + MenuItem xxx = new MenuItem("xxx"); + MenuItem Dance = new MenuItem("Balla"); + Menu info = new Menu("?"); + MenuItem Porky = new MenuItem("Informazioni sul programmatore"); + MenuItem l = new MenuItem("Legenda Comandi"); + MenuItem RobotList = new MenuItem("Lista robot"); +} + + + + -- cgit v1.3