1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
Copyright 2009 Sebastiano Tronto <sebastiano@luganega.org>
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;
public static JPanel[] pannello = new JPanel[5];
public OptionFrame() {
super( "JBriscola - " + main.stringaModificaOpzioni );
ok = new JButton( "OK" );
ok.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
try {
formatter = new Formatter( "JBriscolaConfig.txt" );
} catch ( Exception ex ) {
JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex );
}
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;
default:
lang = "it";
break;
}
String suonosiono;
if ( suono.isSelected() )
suonosiono = "suono=si";
else
suonosiono = "suono=no";
formatter.format( lang );
formatter.format( "\n" );
formatter.format( suonosiono );
formatter.format( "\n" );
formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() );
formatter.close();
main.settaOpzioni();
OptionFrame.this.dispose();
//JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE );
}
});
annulla = new JButton( main.stringaAnnulla );
annulla.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
OptionFrame.this.dispose();
}
});
scegliColore = new JButton( " " );
scegliColore.setBackground( main.color );
scegliColore.addActionListener( new ActionListener() {
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 );
}
} );
lingua = new JLabel( main.stringaLingua );
sfondo = new JLabel( main.stringaSfondo );
String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV };
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;
selezionaLingua.setSelectedIndex( linguaPreselezionata );
suono = new JCheckBox( main.stringaSuono );
suono.setSelected( main.sound );
pannello[0] = new JPanel( new GridLayout( 3, 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[4].add( ok );
pannello[4].add( annulla );
pannello[3].add( sfondo );
pannello[3].add( scegliColore );
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] );
add( pannello[0], BorderLayout.CENTER );
add( pannello[4], BorderLayout.SOUTH );
}
}
|