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! --- .../all_versions/0.3/0.3.2/src/OptionFrame.java | 169 +++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100755 JBriscola/all_versions/0.3/0.3.2/src/OptionFrame.java (limited to 'JBriscola/all_versions/0.3/0.3.2/src/OptionFrame.java') diff --git a/JBriscola/all_versions/0.3/0.3.2/src/OptionFrame.java b/JBriscola/all_versions/0.3/0.3.2/src/OptionFrame.java new file mode 100755 index 0000000..30359f0 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/OptionFrame.java @@ -0,0 +1,169 @@ +/* +Copyright 2009-2010 Sebastiano Tronto + +This file is part of JBriscola. + + JBriscola is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + JBriscola is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JBriscola; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +import java.util.Formatter; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class OptionFrame extends JFrame { + + public static Main main = new Main(); + public static Formatter formatter; + public static JButton ok, annulla, scegliColore; + public static JLabel lingua, sfondo; + public static JComboBox selezionaLingua; + public static JCheckBox suono, tastiRapidi; + public static JPanel[] pannello = new JPanel[6]; + + public OptionFrame() { + + super( "JBriscola - " + main.stringaModificaOpzioni ); + + ok = new JButton( "OK" ); + ok.addActionListener( new ActionListener() { + + /* Quando le modifiche vengono confermate premendo ok, viene scritto + * il file di configurazione (o aggiornato) se possibile, e modificate + * le impostazioni attuali. */ + public void actionPerformed( ActionEvent e ) { + + try { + formatter = new Formatter( "JBriscolaConfig.txt" ); + } catch ( Exception ex ) { + JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); + } + + String lang; + + switch ( selezionaLingua.getSelectedIndex() ) { + case 0: + lang = "it"; + break; + case 1: + lang = "la"; + break; + case 2: + lang = "bl"; + break; + case 3: + lang = "bv"; + break; + case 4: + lang = "en"; + break; + default: + lang = "it"; + break; + } + + String suonosiono, tastisiono; + + if ( suono.isSelected() ) + suonosiono = "suono=si"; + else + suonosiono = "suono=no"; + if ( tastiRapidi.isSelected() ) + tastisiono = "tasti=si"; + else + tastisiono = "tasti=no"; + + formatter.format( lang ); + formatter.format( "\n" ); + formatter.format( suonosiono ); + formatter.format( "\n" ); + formatter.format( tastisiono ); + formatter.format( "\n" ); + formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); + formatter.close(); + + main.settaOpzioni(); + + OptionFrame.this.dispose(); + } + }); + + annulla = new JButton( main.stringaAnnulla ); + annulla.addActionListener( new ActionListener() { + /* Se l'utente annulla viene chiusa la finestra senza fare nulla. */ + public void actionPerformed( ActionEvent e ) { + OptionFrame.this.dispose(); + } + }); + + scegliColore = new JButton( " " ); + scegliColore.setBackground( main.color ); + scegliColore.addActionListener( new ActionListener() { + /* Permette di scegliere il colore dello sfondo. */ + public void actionPerformed( ActionEvent e ) { + Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); + if ( colore != null ) + main.color = colore; + OptionFrame.scegliColore.setBackground( main.color ); + } + } ); + + /* Vengono impostati e disegnati i vari componenti. */ + lingua = new JLabel( main.stringaLingua ); + sfondo = new JLabel( main.stringaSfondo ); + String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV, main.stringaEN }; + selezionaLingua = new JComboBox( lingueDaSelezionare ); + int linguaPreselezionata = 0; + + if ( main.lang.equals( "it" ) ) + linguaPreselezionata = 0; + else if ( main.lang.equals( "la" ) ) + linguaPreselezionata = 1; + else if ( main.lang.equals( "bl" ) ) + linguaPreselezionata = 2; + else if ( main.lang.equals( "bv" ) ) + linguaPreselezionata = 3; + else if ( main.lang.equals( "en" ) ) + linguaPreselezionata = 4; + + selezionaLingua.setSelectedIndex( linguaPreselezionata ); + suono = new JCheckBox( main.stringaSuono ); + suono.setSelected( main.sound ); + tastiRapidi = new JCheckBox( main.stringaTasti ); + tastiRapidi.setSelected( main.keys ); + + pannello[0] = new JPanel( new GridLayout( 4, 1 ) ); + pannello[1] = new JPanel( new FlowLayout() ); + pannello[2] = new JPanel( new FlowLayout() ); + pannello[3] = new JPanel( new FlowLayout() ); + pannello[4] = new JPanel( new FlowLayout() ); + pannello[5] = new JPanel( new FlowLayout() ); + pannello[5].add( ok ); + pannello[5].add( annulla ); + pannello[4].add( sfondo ); + pannello[4].add( scegliColore ); + pannello[3].add( tastiRapidi ); + pannello[2].add( suono ); + pannello[1].add( lingua ); + pannello[1].add( selezionaLingua ); + pannello[0].add( pannello[1] ); + pannello[0].add( pannello[2] ); + pannello[0].add( pannello[3] ); + pannello[0].add( pannello[4] ); + add( pannello[0], BorderLayout.CENTER ); + add( pannello[5], BorderLayout.SOUTH ); + } +} -- cgit v1.3