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 /JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java | |
| download | ancient-projects-7167b4341ef290d56fb96e2af10883a4b925d83b.tar.gz ancient-projects-7167b4341ef290d56fb96e2af10883a4b925d83b.zip | |
Diffstat (limited to 'JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java')
| -rwxr-xr-x | JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java b/JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java new file mode 100755 index 0000000..a93899f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of JBriscola. | ||
| 5 | |||
| 6 | JBriscola 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 | JBriscola 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 JBriscola; 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 java.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | public static Main main = new Main(); | ||
| 29 | public static Formatter formatter; | ||
| 30 | public static JButton ok, annulla, scegliColore; | ||
| 31 | public static JLabel lingua, sfondo; | ||
| 32 | public static JComboBox selezionaLingua; | ||
| 33 | public static JCheckBox suono; | ||
| 34 | public static JPanel[] pannello = new JPanel[5]; | ||
| 35 | public OptionFrame() { | ||
| 36 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 37 | ok = new JButton( "OK" ); | ||
| 38 | ok.addActionListener( new ActionListener() { | ||
| 39 | public void actionPerformed( ActionEvent e ) { | ||
| 40 | try { | ||
| 41 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 42 | } catch ( Exception ex ) { | ||
| 43 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex ); | ||
| 44 | } | ||
| 45 | String lang; | ||
| 46 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 47 | case 0: | ||
| 48 | lang = "it"; | ||
| 49 | break; | ||
| 50 | case 1: | ||
| 51 | lang = "la"; | ||
| 52 | break; | ||
| 53 | case 2: | ||
| 54 | lang = "bl"; | ||
| 55 | break; | ||
| 56 | case 3: | ||
| 57 | lang = "bv"; | ||
| 58 | break; | ||
| 59 | default: | ||
| 60 | lang = "it"; | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | String suonosiono; | ||
| 64 | if ( suono.isSelected() ) | ||
| 65 | suonosiono = "suono=si"; | ||
| 66 | else | ||
| 67 | suonosiono = "suono=no"; | ||
| 68 | formatter.format( lang ); | ||
| 69 | formatter.format( "\n" ); | ||
| 70 | formatter.format( suonosiono ); | ||
| 71 | formatter.format( "\n" ); | ||
| 72 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 73 | formatter.close(); | ||
| 74 | main.settaOpzioni(); | ||
| 75 | OptionFrame.this.dispose(); | ||
| 76 | //JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 77 | } | ||
| 78 | }); | ||
| 79 | annulla = new JButton( main.stringaAnnulla ); | ||
| 80 | annulla.addActionListener( new ActionListener() { | ||
| 81 | public void actionPerformed( ActionEvent e ) { | ||
| 82 | OptionFrame.this.dispose(); | ||
| 83 | } | ||
| 84 | }); | ||
| 85 | scegliColore = new JButton( " " ); | ||
| 86 | scegliColore.setBackground( main.color ); | ||
| 87 | scegliColore.addActionListener( new ActionListener() { | ||
| 88 | public void actionPerformed( ActionEvent e ) { | ||
| 89 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 90 | if ( colore != null ) | ||
| 91 | main.color = colore; | ||
| 92 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 93 | } | ||
| 94 | } ); | ||
| 95 | lingua = new JLabel( main.stringaLingua ); | ||
| 96 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 97 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV }; | ||
| 98 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 99 | int linguaPreselezionata = 0; | ||
| 100 | if ( main.lang.equals( "it" ) ) | ||
| 101 | linguaPreselezionata = 0; | ||
| 102 | else if ( main.lang.equals( "la" ) ) | ||
| 103 | linguaPreselezionata = 1; | ||
| 104 | else if ( main.lang.equals( "bl" ) ) | ||
| 105 | linguaPreselezionata = 2; | ||
| 106 | else if ( main.lang.equals( "bv" ) ) | ||
| 107 | linguaPreselezionata = 3; | ||
| 108 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 109 | suono = new JCheckBox( main.stringaSuono ); | ||
| 110 | suono.setSelected( main.sound ); | ||
| 111 | pannello[0] = new JPanel( new GridLayout( 3, 1 ) ); | ||
| 112 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 113 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 114 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 115 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 116 | pannello[4].add( ok ); | ||
| 117 | pannello[4].add( annulla ); | ||
| 118 | pannello[3].add( sfondo ); | ||
| 119 | pannello[3].add( scegliColore ); | ||
| 120 | pannello[2].add( suono ); | ||
| 121 | pannello[1].add( lingua ); | ||
| 122 | pannello[1].add( selezionaLingua ); | ||
| 123 | pannello[0].add( pannello[1] ); | ||
| 124 | pannello[0].add( pannello[2] ); | ||
| 125 | pannello[0].add( pannello[3] ); | ||
| 126 | add( pannello[0], BorderLayout.CENTER ); | ||
| 127 | add( pannello[4], BorderLayout.SOUTH ); | ||
| 128 | } | ||
| 129 | } | ||
