/* Copyright 2009 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; public static JLabel lingua; public static JComboBox selezionaLingua; public static JPanel pannello1, pannello2; 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; default: lang = "it"; break; } formatter.format( lang ); formatter.close(); main.settaOpzioni(); main.frame.pannello.repaint(); main.frame.repaint(); 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(); } }); lingua = new JLabel( main.stringaLingua ); String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa }; selezionaLingua = new JComboBox( lingueDaSelezionare ); pannello1 = new JPanel( new FlowLayout() ); pannello1.add( lingua ); pannello1.add( selezionaLingua ); pannello2 = new JPanel( new FlowLayout() ); pannello2.add( ok ); pannello2.add( annulla ); add( pannello1, BorderLayout.CENTER ); add( pannello2, BorderLayout.SOUTH ); } }