trojanxem

Untitled

Jul 13th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.42 KB | None | 0 0
  1. import java.awt.EventQueue;
  2.  
  3. import javax.swing.JFrame;
  4. import javax.swing.JLabel;
  5. import javax.swing.JTextField;
  6. import javax.swing.JButton;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.ActionEvent;
  9.  
  10.  
  11.  
  12. public class generator {
  13.    
  14.    
  15.  
  16.    
  17.  
  18.     protected static final int Random = 0;
  19.     private JFrame frmGeneratorHasel;
  20.     private JTextField haslogen;
  21.  
  22.     /**
  23.      * Launch the application.
  24.      */
  25.     public static void main(String[] args) {
  26.         EventQueue.invokeLater(new Runnable() {
  27.             public void run() {
  28.                 try {
  29.                     generator window = new generator();
  30.                     window.frmGeneratorHasel.setVisible(true);
  31.                 } catch (Exception e) {
  32.                     e.printStackTrace();
  33.                 }
  34.             }
  35.         });
  36.     }
  37.  
  38.     /**
  39.      * Create the application.
  40.      */
  41.     public generator() {
  42.         initialize();
  43.     }
  44.  
  45.     /**
  46.      * Initialize the contents of the frame.
  47.      */
  48.     private void initialize() {
  49.         frmGeneratorHasel = new JFrame();
  50.         frmGeneratorHasel.setTitle("Generator hasel");
  51.         frmGeneratorHasel.setBounds(100, 100, 462, 146);
  52.         frmGeneratorHasel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  53.         frmGeneratorHasel.getContentPane().setLayout(null);
  54.        
  55.         JLabel lblCreatedByTr = new JLabel("Created by t33r");
  56.         lblCreatedByTr.setBounds(10, 72, 89, 14);
  57.         frmGeneratorHasel.getContentPane().add(lblCreatedByTr);
  58.        
  59.         JLabel lblIleZnakow = new JLabel("Ile znakow:");
  60.         lblIleZnakow.setBounds(10, 11, 55, 14);
  61.         frmGeneratorHasel.getContentPane().add(lblIleZnakow);
  62.        
  63.         final JTextField iloscznakow = new JTextField();
  64.         iloscznakow.setBounds(132, 8, 132, 20);
  65.         frmGeneratorHasel.getContentPane().add(iloscznakow);
  66.         iloscznakow.setColumns(10);
  67.        
  68.         JLabel lblWygenerowaneHaslo = new JLabel("Wygenerowane haslo:");
  69.         lblWygenerowaneHaslo.setBounds(10, 49, 108, 14);
  70.         frmGeneratorHasel.getContentPane().add(lblWygenerowaneHaslo);
  71.        
  72.         haslogen = new JTextField();
  73.         haslogen.setBounds(132, 39, 132, 20);
  74.         frmGeneratorHasel.getContentPane().add(haslogen);
  75.         haslogen.setColumns(10);
  76.        
  77.         JButton btnGeneruj = new JButton("Generuj");
  78.         btnGeneruj.addActionListener(new ActionListener() {
  79.             public void actionPerformed(ActionEvent arg0) {
  80.                 char[] znaki_specjalne = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '=', '+', '/', '.', ',', '<', '>', ';', ':', '[', ']'};
  81.                 char[] cyfry = {'0','1','2','3','4','5','6','7','8','9'};
  82.                 char[] literymale = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','q','y','w','x','z'};
  83.                 char[] literyduze = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','R','S','T','U','Q','Y','W','X','Z'};
  84.                 int ilosc_znakow = new Integer(iloscznakow.getText());
  85.                 int i = 0;
  86.                 char[] haslo = new char[60];
  87.                 for(i = 0 ; i <=ilosc_znakow;i++)
  88.                 {
  89.                     haslo[i] = znaki_specjalne[Random];
  90.                     i++;
  91.                     haslo[i] = cyfry[Random];
  92.                     i++;
  93.                     haslo[i] = literymale[Random];
  94.                     i++;
  95.                     haslo[i] = literyduze[Random];
  96.                     i++;                   
  97.                    
  98.                 }
  99.                
  100.                
  101.                   String str = new String(haslo);
  102.                
  103.                 haslogen.setText(str);
  104.                  
  105.             }
  106.         });
  107.         btnGeneruj.setBounds(292, 7, 132, 23);
  108.         frmGeneratorHasel.getContentPane().add(btnGeneruj);
  109.        
  110.         JButton btnZapiszDoPliku = new JButton("Zapisz do pliku");
  111.         btnZapiszDoPliku.addActionListener(new ActionListener() {
  112.             public void actionPerformed(ActionEvent e) {
  113.             }
  114.         });
  115.         btnZapiszDoPliku.setBounds(292, 45, 132, 23);
  116.         frmGeneratorHasel.getContentPane().add(btnZapiszDoPliku);
  117.     }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment