diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-03-26 19:27:18 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-03-26 19:27:18 +0100 |
| commit | 7167b4341ef290d56fb96e2af10883a4b925d83b (patch) | |
| tree | 1eb1b9e5ab82ddd89540e68d6b22ae69514575c6 /robottino/all_versions/v4.0.1/src/Frame.java | |
| download | ancient-projects-7167b4341ef290d56fb96e2af10883a4b925d83b.tar.gz ancient-projects-7167b4341ef290d56fb96e2af10883a4b925d83b.zip | |
Diffstat (limited to 'robottino/all_versions/v4.0.1/src/Frame.java')
| -rwxr-xr-x | robottino/all_versions/v4.0.1/src/Frame.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/robottino/all_versions/v4.0.1/src/Frame.java b/robottino/all_versions/v4.0.1/src/Frame.java new file mode 100755 index 0000000..8ec087b --- /dev/null +++ b/robottino/all_versions/v4.0.1/src/Frame.java | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2008, 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of Robottino. | ||
| 5 | |||
| 6 | Robottino is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | Robottino is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with Robottino; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import javax.swing.*; | ||
| 23 | import java.awt.event.*; | ||
| 24 | |||
| 25 | public class Frame extends JFrame { | ||
| 26 | public class Listener implements ActionListener { | ||
| 27 | public void actionPerformed( ActionEvent e ) { | ||
| 28 | if ( e.getSource() == exit ) | ||
| 29 | System.exit(0); | ||
| 30 | else if ( e.getSource() == informazioni ) | ||
| 31 | JOptionPane.showMessageDialog( main.frame, "info", "Robottino v4.0 - Informazioni", JOptionPane.INFORMATION_MESSAGE ); | ||
| 32 | else if ( e.getSource() == nuovo ) { | ||
| 33 | String nome = JOptionPane.showInputDialog( main.frame, "Inserire il nome del nuovo robottino:", "Robot " + ( ++main.robots ) ); | ||
| 34 | if ( nome != null ) | ||
| 35 | main.list.newRobot( nome ); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | public static Listener listener; | ||
| 40 | public static Main main; | ||
| 41 | public static JMenuBar barraMenu = new JMenuBar(); | ||
| 42 | public static JMenu file = new JMenu( "File" ); | ||
| 43 | public static JMenu info = new JMenu( "?" ); | ||
| 44 | public static JMenuItem exit = new JMenuItem( "Esci" ); | ||
| 45 | public static JMenuItem informazioni = new JMenuItem( "Informazioni" ); | ||
| 46 | public static JMenuItem nuovo = new JMenuItem( "Nuovo Robot" ); | ||
| 47 | public Frame() { | ||
| 48 | super( "Robottino versione 4.0" ); | ||
| 49 | listener = new Listener(); | ||
| 50 | main = new Main(); | ||
| 51 | exit.addActionListener( listener ); | ||
| 52 | exit.setMnemonic( 'E' ); | ||
| 53 | informazioni.addActionListener( listener ); | ||
| 54 | informazioni.setMnemonic( 'I' ); | ||
| 55 | nuovo.addActionListener( listener ); | ||
| 56 | nuovo.setMnemonic( 'N' ); | ||
| 57 | file.add( exit ); | ||
| 58 | file.add( nuovo ); | ||
| 59 | file.setMnemonic( 'F' ); | ||
| 60 | info.add( informazioni ); | ||
| 61 | info.setMnemonic( '?' ); | ||
| 62 | barraMenu.add( file ); | ||
| 63 | barraMenu.add( info ); | ||
| 64 | setJMenuBar( barraMenu ); | ||
| 65 | } | ||
| 66 | } \ No newline at end of file | ||
