Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
JaVi - Java Vigenere - Frame1.java

Frame1.java

Caricato da: Teutoburgo
Scarica il programma completo

  1. /*
  2.        JaVi v0.8 - JavaVigenere -   A Java implementation of the Vigenere
  3.                                     cryptographical algorithm
  4.                                     Un'implementazione Java dell'algoritmo di
  5.                                     Vigenere per la crittografia
  6.     Copyright (C) 2002 Pierre Blanc
  7.     Pierre Blanc: pierre@trek.eu.org , blanc_teutoburgo@yahoo.it
  8.     http://it.geocities.com/teutoburgo                (italiano)
  9.     http://it.geocities.com/teutoburgo/indexEn.html   (english)
  10.  
  11.     This program is free software; you can redistribute it and/or modify
  12.     it under the terms of the GNU General Public License as published by
  13.     the Free Software Foundation; either version 2 of the License.
  14.  
  15.     This program is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.     GNU General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU General Public License
  21.     along with this program; if not, write to the Free Software
  22.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23.     or go to      http://www.gnu.org/copyleft/gpl.html
  24.  
  25.  
  26.     Questo  programma è  software  libero; è  lecito redistribuirlo  o
  27.     modificarlo secondo i termini  della Licenza Pubblica Generica GNU
  28.     come è pubblicata dalla Free  Software Foundation, o la versione 2
  29.     della licenza.
  30.     Questo programma  è distribuito nella  speranza che sia  utile, ma
  31.     SENZA  ALCUNA GARANZIA;  senza  neppure la  garanzia implicita  di
  32.     NEGOZIABILITÀ  o di  APPLICABILITÀ PER  UN PARTICOLARE  SCOPO.  Si
  33.     veda la Licenza Pubblica Generica GNU per avere maggiori dettagli.
  34.  
  35.     Questo  programma deve  essere  distribuito assieme  ad una  copia
  36.     della Licenza Pubblica Generica GNU;  in caso contrario, se ne può
  37.     ottenere  una scrivendo  alla Free  Software Foundation,  Inc., 59
  38.     Temple Place, Suite 330, Boston, MA 02111-1307 USA  oppure da
  39.     http://www.gnu.org/copyleft/gpl.html
  40.  
  41. */
  42.  
  43. import java.awt.*;
  44. import java.awt.event.*;
  45. import javax.swing.*;
  46. import javax.swing.event.*;
  47. import java.io.*;
  48.  
  49.  
  50. public class Frame1 extends JFrame {
  51.   Vigenere vig = new Vigenere();
  52.   int about=0;
  53.  
  54.   JPanel contentPane;
  55.   BorderLayout borderLayout1 = new BorderLayout();
  56.   JPanel jPanel1 = new JPanel();
  57.   BorderLayout borderLayout2 = new BorderLayout();
  58.   JPanel jPNorth = new JPanel();
  59.   JPanel jPCenter = new JPanel();
  60.   JPanel jPSouth = new JPanel();
  61.   JPanel jPanel2 = new JPanel();
  62.   JPanel jPanel3 = new JPanel();
  63.   JPanel jPanel4 = new JPanel();
  64.   BorderLayout borderLayout4 = new BorderLayout();
  65.   JPanel jPanel5 = new JPanel();
  66.   JPanel jPanel6 = new JPanel();
  67.   JPanel jPanel7 = new JPanel();
  68.   JPanel jPanel9 = new JPanel();
  69.   JPanel jPNord1 = new JPanel();
  70.   JPanel jPSud1 = new JPanel();
  71.   BorderLayout borderLayout6 = new BorderLayout();
  72.   GridLayout gridLayout1 = new GridLayout();
  73.   JLabel jLabel1 = new JLabel();
  74.   JLabel jLabel2 = new JLabel();
  75.   JLabel jLabel3 = new JLabel();
  76.   JLabel jLabel4 = new JLabel();
  77.   FlowLayout flowLayout1 = new FlowLayout();
  78.   JLabel jLabel6 = new JLabel();
  79.   JLabel jLabel5 = new JLabel();
  80.   JPanel jPanel13 = new JPanel();
  81.   JPanel jPanel15 = new JPanel();
  82.   JPanel jPanel16 = new JPanel();
  83.   JScrollPane jScrollPane1 = new JScrollPane();
  84.   JTextArea jTextAreaChiave = new JTextArea();
  85.   JScrollPane jScrollPane2 = new JScrollPane();
  86.   JTextArea jTextAreaCrittata = new JTextArea();
  87.   JScrollPane jScrollPane3 = new JScrollPane();
  88.   JTextArea jTextAreaFrase = new JTextArea();
  89.   JButton jButton1 = new JButton();
  90.   JButton engl = new JButton();
  91.   JButton jButton2 = new JButton();
  92.   JButton jButton3 = new JButton();
  93.   JLabel jLabel7 = new JLabel();
  94.   FlowLayout flowLayout2 = new FlowLayout();
  95.   GridLayout gridLayout2 = new GridLayout();
  96.   GridLayout gridLayout3 = new GridLayout();
  97.   GridLayout gridLayout4 = new GridLayout();
  98.   GridLayout gridLayout5 = new GridLayout();
  99.   JCheckBox jCheckBox1 = new JCheckBox();
  100.   JCheckBox jCheckBox2 = new JCheckBox();
  101.   JButton jButton4 = new JButton();
  102.   JLabel jLabel8 = new JLabel();
  103.   JLabel jLabel9 = new JLabel();
  104.   BorderLayout borderLayout3 = new BorderLayout();
  105.   JMenuBar jMenuBar1 = new JMenuBar();
  106.   JMenu jMenu1 = new JMenu();
  107.   JMenu jMenuApri = new JMenu();
  108.   JMenuItem jMenuItemFrase = new JMenuItem();
  109.   JMenuItem jMenuItemChiave = new JMenuItem();
  110.   JMenuItem jMenuItemCrittata = new JMenuItem();
  111.   JMenu jMenu3 = new JMenu();
  112.   JMenuItem jMenuItem5 = new JMenuItem();
  113.   JFileChooser jFileChooser1 = new JFileChooser();
  114.   JMenu jMenuSalva = new JMenu();
  115.   JMenuItem jMenuItemFraseS = new JMenuItem();
  116.   JMenuItem jMenuItemChiaveS = new JMenuItem();
  117.   JMenuItem jMenuItemCrittataS = new JMenuItem();
  118.  
  119.   //Construct the frame
  120.   public Frame1() {
  121.     enableEvents(AWTEvent.WINDOW_EVENT_MASK);
  122.     try {
  123.       jbInit();
  124.     }
  125.     catch(Exception e) {
  126.       e.printStackTrace();
  127.     }
  128.   }
  129.   //Component initialization
  130.   private void jbInit() throws Exception  {
  131.     //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
  132.     contentPane = (JPanel) this.getContentPane();
  133.     contentPane.setPreferredSize(new Dimension(1000, 1000));
  134.     contentPane.setLayout(borderLayout1);
  135.     this.setJMenuBar(jMenuBar1);
  136.     this.setSize(new Dimension(650, 400));
  137.     this.setTitle("Frame Title");
  138.     jPanel1.setSize(new Dimension(650,300));
  139.     jPNorth.setSize(new Dimension(650,100));
  140.     jPCenter.setSize(new Dimension(650,150));
  141.     jPSouth.setSize(new Dimension(650,50));
  142.     jPanel1.setLayout(borderLayout2);
  143.     jPNorth.setBackground(Color.white);
  144.     jPNorth.setLayout(borderLayout6);
  145.     jPSouth.setBackground(Color.orange);
  146.     jPanel4.setLayout(gridLayout4);
  147.     jPanel4.setBackground(Color.orange);
  148.     jPanel4.setPreferredSize(new Dimension(90, 60));
  149.     jPCenter.setLayout(borderLayout4);
  150.     jPanel2.setBackground(Color.orange);
  151.     jPanel2.setPreferredSize(new Dimension(90, 10));
  152.     jPanel2.setLayout(gridLayout2);
  153.     jPanel5.setMinimumSize(new Dimension(30, 10));
  154.     jPanel5.setPreferredSize(new Dimension(30, 10));
  155.     jPanel5.setLayout(borderLayout3);
  156.     jPanel6.setBackground(new Color(255, 223, 0));
  157.     jPanel6.setMinimumSize(new Dimension(30, 10));
  158.     jPanel6.setPreferredSize(new Dimension(30, 10));
  159.     jPanel9.setBackground(Color.orange);
  160.     jPanel9.setPreferredSize(new Dimension(80, 70));
  161.     jPNord1.setLayout(gridLayout1);
  162.     gridLayout1.setColumns(1);
  163.     gridLayout1.setRows(2);
  164.     jLabel1.setHorizontalAlignment(SwingConstants.LEFT);
  165.     jLabel1.setText("JaVi - v0.8 - A Java implementation of the Vigenere algorithm.");
  166.     jLabel2.setToolTipText("");
  167.     jLabel2.setHorizontalAlignment(SwingConstants.LEFT);
  168.     jLabel2.setText("Copyright (C) 2002 Pierre Blanc - "+
  169.         "blanc_teutoburgo@yahoo.it - http://it.geocities.com/teutoburgo");
  170.     jLabel3.setBackground(Color.pink);
  171.     jLabel3.setToolTipText("");
  172.     jLabel3.setHorizontalAlignment(SwingConstants.LEFT);
  173.     jLabel3.setHorizontalTextPosition(SwingConstants.LEFT);
  174.     jLabel3.setText("This software is under the GPL license v.2");
  175.     jLabel4.setBackground(Color.pink);
  176.     jLabel4.setToolTipText("");
  177.     jLabel4.setHorizontalAlignment(SwingConstants.RIGHT);
  178.     jLabel4.setHorizontalTextPosition(SwingConstants.RIGHT);
  179.     jLabel4.setText("b<AE=<");
  180.     jPSud1.setLayout(flowLayout1);
  181.     flowLayout1.setAlignment(FlowLayout.LEFT);
  182.     flowLayout1.setHgap(10);
  183.     flowLayout1.setVgap(0);
  184.     jLabel6.setToolTipText("");
  185.     jLabel6.setHorizontalAlignment(SwingConstants.CENTER);
  186.     jLabel6.setHorizontalTextPosition(SwingConstants.CENTER);
  187.     jLabel6.setText("50%");
  188.     jLabel5.setToolTipText("");
  189.     jLabel5.setHorizontalAlignment(SwingConstants.CENTER);
  190.     jLabel5.setText("Forza chiave:");
  191.     jPanel3.setMinimumSize(new Dimension(30, 10));
  192.     jPanel3.setPreferredSize(new Dimension(30, 10));
  193.     jPanel3.setLayout(gridLayout3);
  194.     jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  195.     jScrollPane1.getViewport().setBackground(Color.orange);
  196.     jScrollPane1.setBorder(null);
  197.     jScrollPane1.setPreferredSize(new Dimension(200, 40));
  198.     jTextAreaChiave.setPreferredSize(new Dimension(100, 17));
  199.     jTextAreaChiave.setLineWrap(true);
  200.     jTextAreaChiave.setRows(5);
  201.     jTextAreaChiave.addKeyListener(new java.awt.event.KeyAdapter() {
  202.       public void keyTyped(KeyEvent e) {
  203.         jTextAreaChiave_keyTyped(e);
  204.       }
  205.     });
  206.     jScrollPane2.setPreferredSize(new Dimension(200, 40));
  207.     jTextAreaCrittata.setPreferredSize(new Dimension(100, 17));
  208.     jTextAreaCrittata.setColumns(20);
  209.     jTextAreaCrittata.setLineWrap(true);
  210.     jTextAreaCrittata.setRows(5);
  211.     jScrollPane3.setPreferredSize(new Dimension(200, 40));
  212.     jTextAreaFrase.setMaximumSize(new Dimension(100, 17));
  213.     jTextAreaFrase.setMinimumSize(new Dimension(100, 17));
  214.     jTextAreaFrase.setPreferredSize(new Dimension(100, 17));
  215.     jTextAreaFrase.setText("inserisci qui la tua frase");
  216.     jTextAreaFrase.setLineWrap(true);
  217.     jTextAreaFrase.setRows(5);
  218.     jPanel13.setLayout(flowLayout2);
  219.     jPanel13.setBackground(Color.orange);
  220.     jPanel13.setPreferredSize(new Dimension(200, 70));
  221.     jButton1.setBackground(new Color(131, 0, 255));
  222.     jButton1.setForeground(Color.white);
  223.     jButton1.setText("English");
  224.     jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
  225.       public void mouseClicked(MouseEvent e) {
  226.         jButton1_mouseClicked(e);
  227.       }
  228.     });
  229.     engl.setBackground(new Color(79, 151, 39));
  230.     engl.setForeground(Color.white);
  231.     engl.setPreferredSize(new Dimension(79, 79));
  232.     engl.setText("italiano");
  233.     engl.addMouseListener(new java.awt.event.MouseAdapter() {
  234.       public void mouseClicked(MouseEvent e) {
  235.         engl_mouseClicked(e);
  236.       }
  237.     });
  238.     jPanel16.setBackground(Color.darkGray);
  239.     jPanel16.setPreferredSize(new Dimension(200, 79));
  240.     jPanel15.setBackground(Color.darkGray);
  241.     jPanel15.setPreferredSize(new Dimension(200, 80));
  242.     jButton2.setText("decritta");
  243.     jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
  244.       public void mouseClicked(MouseEvent e) {
  245.         jButton2_mouseClicked(e);
  246.       }
  247.     });
  248.     jButton3.setPreferredSize(new Dimension(79, 27));
  249.     jButton3.setText("critta");
  250.     jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
  251.       public void mousePressed(MouseEvent e) {
  252.         jButton3_mousePressed(e);
  253.       }
  254.     });
  255.     jLabel7.setText("Chiave:");
  256.     jPanel1.setPreferredSize(new Dimension(1000, 100));
  257.     gridLayout2.setColumns(1);
  258.     gridLayout2.setRows(3);
  259.     jPanel7.setPreferredSize(new Dimension(79, 79));
  260.     jPanel7.setLayout(gridLayout5);
  261.     gridLayout3.setColumns(1);
  262.     gridLayout3.setRows(3);
  263.     gridLayout4.setColumns(1);
  264.     gridLayout4.setRows(3);
  265.     jCheckBox1.setSelected(true);
  266.     jCheckBox1.setText("Chiave editabile");
  267.     jCheckBox1.addItemListener(new java.awt.event.ItemListener() {
  268.       public void itemStateChanged(ItemEvent e) {
  269.         jCheckBox1_itemStateChanged(e);
  270.       }
  271.     });
  272.     jCheckBox2.setSelected(true);
  273.     jCheckBox2.setText("Chiave visibile");
  274.     jCheckBox2.addItemListener(new java.awt.event.ItemListener() {
  275.       public void itemStateChanged(ItemEvent e) {
  276.         jCheckBox2_itemStateChanged(e);
  277.       }
  278.     });
  279.     jButton4.setText("Resetta chiave");
  280.     jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
  281.       public void mouseClicked(MouseEvent e) {
  282.         jButton4_mouseClicked(e);
  283.       }
  284.     });
  285.     jLabel8.setForeground(Color.white);
  286.     jLabel8.setToolTipText("");
  287.     jLabel8.setText("Frase Crittata:");
  288.     jLabel9.setForeground(Color.white);
  289.     jLabel9.setText("Frase:");
  290.     jMenu1.setText("File");
  291.     jMenuApri.setText("Apri");
  292.     jMenuItemFrase.setText("Frase");
  293.     jMenuItemFrase.addMouseListener(new java.awt.event.MouseAdapter() {
  294.       public void mousePressed(MouseEvent e) {
  295.         jMenuItemFrase_mousePressed(e);
  296.       }
  297.     });
  298.     jMenuItemChiave.setText("Chiave");
  299.     jMenuItemChiave.addMouseListener(new java.awt.event.MouseAdapter() {
  300.       public void mousePressed(MouseEvent e) {
  301.         jMenuItemChiave_mousePressed(e);
  302.       }
  303.     });
  304.     jMenuItemCrittata.setActionCommand("Frase Crittata");
  305.     jMenuItemCrittata.setText("Frase Crittata");
  306.     jMenuItemCrittata.addMouseListener(new java.awt.event.MouseAdapter() {
  307.       public void mousePressed(MouseEvent e) {
  308.         jMenuItemCrittata_mousePressed(e);
  309.       }
  310.     });
  311.     jMenu3.setText("Help");
  312.     jMenuItem5.setText("About...");
  313.     jMenuItem5.addMouseListener(new java.awt.event.MouseAdapter() {
  314.       public void mousePressed(MouseEvent e) {
  315.         jMenuItem5_mousePressed(e);
  316.       }
  317.     });
  318.     jMenuSalva.setText("Salva");
  319.     jMenuItemFraseS.setText("Frase");
  320.     jMenuItemFraseS.addMouseListener(new java.awt.event.MouseAdapter() {
  321.       public void mousePressed(MouseEvent e) {
  322.         jMenuItemFraseS_mousePressed(e);
  323.       }
  324.     });
  325.     jMenuItemChiaveS.setText("Chiave");
  326.     jMenuItemChiaveS.addMouseListener(new java.awt.event.MouseAdapter() {
  327.       public void mousePressed(MouseEvent e) {
  328.         jMenuItemChiaveS_mousePressed(e);
  329.       }
  330.     });
  331.     jMenuItemCrittataS.setText("Crittata");
  332.     jMenuItemCrittataS.addMouseListener(new java.awt.event.MouseAdapter() {
  333.       public void mousePressed(MouseEvent e) {
  334.         jMenuItemCrittataS_mousePressed(e);
  335.       }
  336.     });
  337.     contentPane.add(jPanel1, BorderLayout.CENTER);
  338.     jPanel1.add(jPNorth, BorderLayout.NORTH);
  339.     jPNorth.add(jPNord1,  BorderLayout.NORTH);
  340.     jPNord1.add(jLabel1, null);
  341.     jPNord1.add(jLabel2, null);
  342.     jPNorth.add(jPSud1, BorderLayout.SOUTH);
  343.     jPSud1.add(jLabel3, null);
  344.     jPSud1.add(jLabel4, null);
  345.     jPanel1.add(jPCenter, BorderLayout.CENTER);
  346.     jPanel1.add(jPSouth, BorderLayout.SOUTH);
  347.     jPSouth.add(jButton4, null);
  348.     jPSouth.add(jCheckBox2, null);
  349.     jPSouth.add(jCheckBox1, null);
  350.     jPCenter.add(jPanel4,  BorderLayout.EAST);
  351.     jPanel4.add(engl, null);
  352.     jPanel4.add(jButton1, null);
  353.     jPanel4.add(jPanel9, null);
  354.     jPCenter.add(jPanel3,  BorderLayout.CENTER);
  355.     jPanel13.add(jLabel7, null);
  356.     jPanel13.add(jScrollPane1, null);
  357.     jScrollPane1.getViewport().add(jTextAreaChiave, null);
  358.     jPanel13.add(jButton3, null);
  359.     jPanel13.add(jButton2, null);
  360.     jPanel3.add(jPanel16, null);
  361.     jPanel16.add(jLabel9, null);
  362.     jPanel16.add(jScrollPane3, null);
  363.     jPanel3.add(jPanel13, null);
  364.     jPanel3.add(jPanel15, null);
  365.     jPanel15.add(jLabel8, null);
  366.     jPanel15.add(jScrollPane2, null);
  367.     jScrollPane2.getViewport().add(jTextAreaCrittata, null);
  368.     jScrollPane3.getViewport().add(jTextAreaFrase, null);
  369.     jPCenter.add(jPanel2,  BorderLayout.WEST);
  370.     jPanel2.add(jPanel7, null);
  371.     jPanel7.add(jLabel5, null);
  372.     jPanel2.add(jPanel5, null);
  373.     jPanel5.add(jLabel6,  BorderLayout.CENTER);
  374.     jPanel2.add(jPanel6, null);
  375.     jMenuBar1.add(jMenu1);
  376.     jMenuBar1.add(jMenu3);
  377.     jMenu1.add(jMenuApri);
  378.     jMenu1.add(jMenuSalva);
  379.     jMenuApri.add(jMenuItemFrase);
  380.     jMenuApri.add(jMenuItemChiave);
  381.     jMenuApri.add(jMenuItemCrittata);
  382.     jMenu3.add(jMenuItem5);
  383.     jMenuSalva.add(jMenuItemFraseS);
  384.     jMenuSalva.add(jMenuItemChiaveS);
  385.     jMenuSalva.add(jMenuItemCrittataS);
  386.     jPanel7.setSize(new Dimension(100,79));
  387.   }
  388.   //Overridden so we can exit when window is closed
  389.   protected void processWindowEvent(WindowEvent e) {
  390.     super.processWindowEvent(e);
  391.     if (e.getID() == WindowEvent.WINDOW_CLOSING) {
  392.       System.exit(0);
  393.     }
  394.   }
  395.  
  396.   void jButton3_mousePressed(MouseEvent e) {
  397.     jTextAreaCrittata.setText(vig.getEncryptedPhrase(jTextAreaFrase.getText(),jTextAreaChiave.getText()));
  398.     jTextAreaFrase.setText("");
  399.   }
  400.  
  401.   void jButton2_mouseClicked(MouseEvent e) {
  402.     jTextAreaFrase.setText(vig.getPhrase(jTextAreaCrittata.getText(),jTextAreaChiave.getText()));
  403.   }
  404.  
  405.   void jTextAreaChiave_keyTyped(KeyEvent e) {
  406.     int accuratezza = vig.getKSPerCent(jTextAreaChiave.getText(),30);
  407.     jLabel6.setText(accuratezza+"%");
  408.     if (accuratezza<60) {
  409.       jPanel6.setBackground(new Color(255,0,0));
  410.     }
  411.     else {
  412.       jPanel6.setBackground(new Color(0,255,0));
  413.     }
  414.  
  415.  
  416.   }
  417.  
  418.   void jButton4_mouseClicked(MouseEvent e) {
  419.     jTextAreaChiave.setText("");
  420.   }
  421.  
  422.   void jCheckBox2_itemStateChanged(ItemEvent e) {
  423.     if (jTextAreaChiave.isVisible()) {
  424.       jTextAreaChiave.setVisible(false);
  425.  
  426.     }
  427.     else {
  428.       jTextAreaChiave.setVisible(true);
  429.     }
  430.  
  431.   }
  432.  
  433.   void jCheckBox1_itemStateChanged(ItemEvent e) {
  434.  
  435.   if (jTextAreaChiave.isEditable()) {
  436.     jTextAreaChiave.setEditable(false);
  437.   }
  438.   else {
  439.     jTextAreaChiave.setEditable(true);
  440.   }
  441.  
  442.   }
  443.  
  444.  
  445.   void englishVersion (){
  446.     jLabel5.setText("Key Strength:");
  447.     jLabel9.setText("Phrase");
  448.     jButton3.setText("Encrypt");
  449.     jLabel7.setText(" Key   ");
  450.     jButton2.setText("Decrypt");
  451.     jLabel8.setText("Encrypted Phrase");
  452.     jCheckBox2.setText("Visible Key    ");
  453.     jCheckBox1.setText("Editable Key    ");
  454.     jButton4.setText("   Reset Key   ");
  455.     jTextAreaFrase.setText("Insert your phrase here");
  456.     //jTextArea1.selectAll();
  457.     jLabel1.setText("JaVi - v0.8 - A Java implementation of the Vigenere"+
  458.                    " algorithm.");
  459.     jLabel3.setText("This software is under the GPL license v.2");
  460.     jMenuApri.setText("Open");
  461.     jMenuSalva.setText("Save");
  462.     jMenuItemFrase.setText("Phrase");
  463.     jMenuItemChiave.setText("Key");
  464.     jMenuItemCrittata.setText("Encrypted");
  465.     jMenuItemFraseS.setText("Phrase");
  466.     jMenuItemChiaveS.setText("Key");
  467.     jMenuItemCrittataS.setText("Encrypted");
  468.     if (about==1) {
  469.       jLabel2.setText(" ...featuring Sara Cristilli and Danila Komar (Swing GUI DJs)");
  470.     }
  471.  
  472.  
  473.  
  474.  
  475.   }
  476.  
  477.   void jButton1_mouseClicked(MouseEvent e) {
  478.     englishVersion();
  479.   }
  480.  
  481.  
  482.  
  483.   void engl_mouseClicked(MouseEvent e) {
  484.     jLabel5.setText("Forza Chiave:");
  485.     jLabel9.setText("Frase");
  486.     jButton3.setText("Critta");
  487.     jLabel7.setText("Chiave");
  488.     jButton2.setText("Decritta");
  489.     jLabel8.setText("Frase Crittata");
  490.     jCheckBox2.setText("Chiave visibile");
  491.     jCheckBox1.setText("Chiave editabile");
  492.     jButton4.setText("Resetta Chiave");
  493.     jTextAreaFrase.setText("Inserisci qui la tua frase");
  494.     //textArea1.selectAll();
  495.     jLabel1.setText("JaVi - v0.8 - Un'implementazione Java dell'algoritmo "+
  496.                    "di Vigenere.");
  497.     jLabel3.setText("Questo software e' tutelato dalla GPL license v.2");
  498.     jMenuApri.setText("Apri");
  499.     jMenuSalva.setText("Salva");
  500.     jMenuItemFrase.setText("Frase");
  501.     jMenuItemChiave.setText("Chiave");
  502.     jMenuItemCrittata.setText("Crittata");
  503.     jMenuItemFraseS.setText("Frase");
  504.     jMenuItemChiaveS.setText("Chiave");
  505.     jMenuItemCrittataS.setText("Crittata");
  506.     if (about==1) {
  507.       jLabel2.setText(" ...con la collaborazione di Sara Cristilli e Danila Komar (Swing GUI)");
  508.     }
  509.   }
  510.   public String readFile(){
  511.     String str="";
  512.     int returnVal = jFileChooser1.showOpenDialog(this);
  513.     int j = 0;
  514.     if(returnVal == JFileChooser.APPROVE_OPTION) {
  515.      try{
  516.         File file = new File(jFileChooser1.getSelectedFile().getAbsolutePath());
  517.         int l=(int)file.length();
  518.         FileReader fr = new FileReader(file);
  519.         char [] arrCar= new char[l];
  520.         while (fr.ready()){
  521.           j += fr.read(arrCar,j,l-j);
  522.         }
  523.         for (int k=0; k<l-1; k++)
  524.           if ((int)arrCar[k]==13)
  525.             if((int)arrCar[k+1]==10){
  526.               arrCar[k]='*';
  527.               arrCar[k+1]='*';
  528.             }
  529.         fr.close();
  530.         str = new String(arrCar,0,j);
  531.  
  532.      } catch(Exception ex){
  533.         ex.printStackTrace();
  534.      }
  535.     }
  536.  
  537.     return str;
  538.   }
  539.  
  540.   public void writeFile(String str){
  541.     try{
  542.       int returnVal = jFileChooser1.showSaveDialog(this);
  543.       if(returnVal == JFileChooser.APPROVE_OPTION) {
  544.         File file = new File(jFileChooser1.getSelectedFile().getAbsolutePath());
  545.         FileWriter fw= new FileWriter(file);
  546.         fw.write(str,0,str.length());
  547.         fw.close();
  548.       }
  549.     }catch(Exception ex){
  550.       ex.printStackTrace();
  551.     }
  552.   }
  553.  
  554.  
  555.   void jMenuItemFrase_mousePressed(MouseEvent e) {
  556.       jTextAreaFrase.setText(readFile());
  557.   }
  558.  
  559.   void jMenuItemChiave_mousePressed(MouseEvent e) {
  560.       jTextAreaChiave.setText(readFile());
  561.   }
  562.  
  563.   void jMenuItemCrittata_mousePressed(MouseEvent e) {
  564.       jTextAreaCrittata.setText(readFile());
  565.   }
  566.  
  567.   void jMenuItemFraseS_mousePressed(MouseEvent e) {
  568.       writeFile(jTextAreaFrase.getText());
  569.   }
  570.  
  571.   void jMenuItemChiaveS_mousePressed(MouseEvent e) {
  572.       writeFile(jTextAreaChiave.getText());
  573.   }
  574.  
  575.   void jMenuItemCrittataS_mousePressed(MouseEvent e) {
  576.       writeFile(jTextAreaCrittata.getText());
  577.   }
  578.  
  579.   void jMenuItem5_mousePressed(MouseEvent e) {
  580.     if(about==0){
  581.       if (jMenuItemChiave.getText().equals("Chiave")) {
  582.          jLabel2.setText(" ...con la collaborazione di Sara Cristilli e Danila Komar (Swing GUI)");
  583.       } else {
  584.          jLabel2.setText(" ...featuring Sara Cristilli and Danila Komar (Swing GUI DJs)");
  585.       }
  586.       about=1;
  587.     } else {
  588.       about=0;
  589.       jLabel2.setText("Copyright (C) 2002 Pierre Blanc - "+
  590.         "blanc_teutoburgo@yahoo.it - http://it.geocities.com/teutoburgo");
  591.     }
  592.   }
  593.  
  594.  
  595.  
  596.  
  597. }