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
Base64 Encoder/Decoder - Main.java

Main.java

Caricato da:
Scarica il programma completo

  1. import java.io.IOException;
  2.  
  3. public class Main extends javax.swing.JFrame{
  4.  
  5.         private static final long serialVersionUID = 1L;
  6.         public Main() {
  7.         initComponents();
  8.     }
  9.     private void initComponents() {
  10.  
  11.         lblinput = new javax.swing.JLabel();
  12.         jsp = new javax.swing.JScrollPane();
  13.         txtinput = new javax.swing.JTextArea();
  14.         lbloutput = new javax.swing.JLabel();
  15.         jsp2 = new javax.swing.JScrollPane();
  16.         txtoutput = new javax.swing.JTextArea();
  17.         cmdenc = new javax.swing.JButton();
  18.         cmddec = new javax.swing.JButton();
  19.         cmdesc = new javax.swing.JButton();
  20.  
  21.         setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  22.         setTitle("Base64 Encode/Decode");
  23.         setResizable(false);
  24.  
  25.         lblinput.setText("Input:");
  26.  
  27.         txtinput.setColumns(20);
  28.         txtinput.setRows(5);
  29.         jsp.setViewportView(txtinput);
  30.  
  31.         lbloutput.setText("Output:");
  32.  
  33.         txtoutput.setColumns(20);
  34.         txtoutput.setRows(5);
  35.         jsp2.setViewportView(txtoutput);
  36.  
  37.         cmdenc.setText("Encode");
  38.         cmdenc.addActionListener(new java.awt.event.ActionListener() {
  39.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  40.                 cmdencActionPerformed(evt);
  41.             }
  42.         });
  43.  
  44.         cmddec.setText("Decode");
  45.         cmddec.addActionListener(new java.awt.event.ActionListener() {
  46.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  47.                 try {
  48.                                         cmddecActionPerformed(evt);
  49.                                 } catch (IOException e) {
  50.                                         e.printStackTrace();
  51.                                 }
  52.             }
  53.         });
  54.  
  55.         cmdesc.setText("Esci");
  56.         cmdesc.addActionListener(new java.awt.event.ActionListener() {
  57.             public void actionPerformed(java.awt.event.ActionEvent evt) {
  58.                 cmdescActionPerformed(evt);
  59.             }
  60.         });
  61.  
  62.         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  63.         getContentPane().setLayout(layout);
  64.         layout.setHorizontalGroup(
  65.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  66.             .addGroup(layout.createSequentialGroup()
  67.                 .addContainerGap()
  68.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  69.                     .addGroup(layout.createSequentialGroup()
  70.                         .addComponent(cmdesc, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
  71.                         .addContainerGap())
  72.                     .addGroup(layout.createSequentialGroup()
  73.                         .addComponent(lblinput)
  74.                         .addGap(355, 355, 355))
  75.                     .addGroup(layout.createSequentialGroup()
  76.                         .addComponent(lbloutput)
  77.                         .addContainerGap(347, Short.MAX_VALUE))
  78.                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  79.                         .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  80.                             .addComponent(jsp2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
  81.                             .addComponent(jsp, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE))
  82.                         .addContainerGap())
  83.                     .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  84.                         .addComponent(cmdenc, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
  85.                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  86.                         .addComponent(cmddec, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
  87.                         .addContainerGap())))
  88.         );
  89.         layout.setVerticalGroup(
  90.             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  91.             .addGroup(layout.createSequentialGroup()
  92.                 .addContainerGap()
  93.                 .addComponent(lblinput)
  94.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  95.                 .addComponent(jsp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  96.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  97.                 .addComponent(lbloutput)
  98.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  99.                 .addComponent(jsp2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  100.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  101.                 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  102.                     .addComponent(cmdenc)
  103.                     .addComponent(cmddec))
  104.                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  105.                 .addComponent(cmdesc)
  106.                 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  107.         );
  108.  
  109.         pack();
  110.     }
  111.  
  112.     private void cmdescActionPerformed(java.awt.event.ActionEvent evt) {
  113.         System.exit(0);
  114.     }
  115.  
  116.     private void cmdencActionPerformed(java.awt.event.ActionEvent evt) {
  117.         Encode Enc = new Encode();
  118.         Enc.execute(txtinput, txtoutput);
  119.     }
  120.  
  121.     private void cmddecActionPerformed(java.awt.event.ActionEvent evt) throws IOException {
  122.         Decode Dec = new Decode();
  123.         Dec.execute(txtinput,txtoutput);
  124.     }
  125.  
  126.     public static void main(String args[]) {
  127.         java.awt.EventQueue.invokeLater(new Runnable() {
  128.             public void run() {
  129.                 new Main().setVisible(true);
  130.             }
  131.         });
  132.     }
  133.     private javax.swing.JButton cmddec;
  134.     private javax.swing.JButton cmdenc;
  135.     private javax.swing.JButton cmdesc;
  136.     private javax.swing.JTextArea txtoutput;
  137.     private javax.swing.JScrollPane jsp;
  138.     private javax.swing.JScrollPane jsp2;
  139.     private javax.swing.JLabel lblinput;
  140.     private javax.swing.JLabel lbloutput;
  141.     private javax.swing.JTextArea txtinput;
  142. }