Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JTextField;
- import javax.swing.JButton;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- public class generator {
- protected static final int Random = 0;
- private JFrame frmGeneratorHasel;
- private JTextField haslogen;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- generator window = new generator();
- window.frmGeneratorHasel.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public generator() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frmGeneratorHasel = new JFrame();
- frmGeneratorHasel.setTitle("Generator hasel");
- frmGeneratorHasel.setBounds(100, 100, 462, 146);
- frmGeneratorHasel.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frmGeneratorHasel.getContentPane().setLayout(null);
- JLabel lblCreatedByTr = new JLabel("Created by t33r");
- lblCreatedByTr.setBounds(10, 72, 89, 14);
- frmGeneratorHasel.getContentPane().add(lblCreatedByTr);
- JLabel lblIleZnakow = new JLabel("Ile znakow:");
- lblIleZnakow.setBounds(10, 11, 55, 14);
- frmGeneratorHasel.getContentPane().add(lblIleZnakow);
- final JTextField iloscznakow = new JTextField();
- iloscznakow.setBounds(132, 8, 132, 20);
- frmGeneratorHasel.getContentPane().add(iloscznakow);
- iloscznakow.setColumns(10);
- JLabel lblWygenerowaneHaslo = new JLabel("Wygenerowane haslo:");
- lblWygenerowaneHaslo.setBounds(10, 49, 108, 14);
- frmGeneratorHasel.getContentPane().add(lblWygenerowaneHaslo);
- haslogen = new JTextField();
- haslogen.setBounds(132, 39, 132, 20);
- frmGeneratorHasel.getContentPane().add(haslogen);
- haslogen.setColumns(10);
- JButton btnGeneruj = new JButton("Generuj");
- btnGeneruj.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- char[] znaki_specjalne = {'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '=', '+', '/', '.', ',', '<', '>', ';', ':', '[', ']'};
- char[] cyfry = {'0','1','2','3','4','5','6','7','8','9'};
- 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'};
- 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'};
- int ilosc_znakow = new Integer(iloscznakow.getText());
- int i = 0;
- char[] haslo = new char[60];
- for(i = 0 ; i <=ilosc_znakow;i++)
- {
- haslo[i] = znaki_specjalne[Random];
- i++;
- haslo[i] = cyfry[Random];
- i++;
- haslo[i] = literymale[Random];
- i++;
- haslo[i] = literyduze[Random];
- i++;
- }
- String str = new String(haslo);
- haslogen.setText(str);
- }
- });
- btnGeneruj.setBounds(292, 7, 132, 23);
- frmGeneratorHasel.getContentPane().add(btnGeneruj);
- JButton btnZapiszDoPliku = new JButton("Zapisz do pliku");
- btnZapiszDoPliku.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- }
- });
- btnZapiszDoPliku.setBounds(292, 45, 132, 23);
- frmGeneratorHasel.getContentPane().add(btnZapiszDoPliku);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment