Академический Документы
Профессиональный Документы
Культура Документы
Nota
____________
CUPRINS:
Listing-ul programului: .......................................................................................................................................................... 4
Bibliografie: ........................................................................................................................................................................... 15
LISTING-UL PROGRAMULUI:
PassEngine.java
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
class PassEngine
{
HomeView.java
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import javax.swing.*;
bAdauga.addActionListener(listener);
bAfiseaza.addActionListener(listener);
public HomeView()
setLayout(new GridLayout(2,1));
bAdauga = new JButton("Adauga date noi");
add(bAdauga);
add(bAfiseaza);
setSize(250,160);
setVisible(true);
setTitle("SmartPass");
AddView.java
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import javax.swing.*;
public AddView()
{
setLayout(new GridLayout(5, 1));
add(tfServiciu);
add(tfParola);
add(bGenereaza);
add(bSalveaza);
add(bHome);
setSize(290,300);
setVisible(false);
setTitle("Adauga date");
}
}
PassModel.java
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.security.SecureRandom;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import com.mysql.cj.xdevapi.Statement;
ShowView view;
Clipboard clipboard =
Toolkit.getDefaultToolkit().getSystemClipboard();
try {
String tampon;
Class.forName("com.mysql.jdbc.Driver") ;
tampon = encoder.encodeToString(p.getBytes());
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost/smartpass","root", "") ;
ResultSet rs = stmt.executeQuery(query);
while ( rs.next() ) {
view.lParola.setText(password);
conn.close();
} catch (Exception e) {
System.err.println(e.getMessage());
}
public void selectData()
try {
Class.forName("com.mysql.jdbc.Driver") ;
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost/smartpass","root", "") ;
ResultSet rs = stmt.executeQuery(query);
while ( rs.next() ) {
view.cbList.addItem(service);
conn.close();
} catch (Exception e) {
System.err.println(e.getMessage());
try
password = encoder.encodeToString(password.getBytes());
service = encoder.encodeToString(service.getBytes());
Class.forName("com.mysql.jdbc.Driver");
conn =
DriverManager.getConnection("jdbc:mysql://localhost/smartpass","root", "");
preparedStmt.execute();
conn.close();
catch(Exception e)
PassController.java
import java.awt.event.*;
import java.util.Random;
HomeView home;
AddView add;
PassModel model;
ShowView show;
this.home = home;
this.add = add;
this.model = model;
this.show = show;
this.model.view = show;
this.home.adaugaAscultator(new PassAscultator());
this.add.adaugaAscultator(new PassAscultator());
this.show.adaugaAscultator(new PassAscultator());
this.show.ascul(new ascult());
@Override
String tampon;
tampon = show.cbList.getSelectedItem().toString();
model.select(tampon);
@Override
if (e.getSource() == home.bAdauga)
add.setVisible(true);
home.setVisible(false);
if (e.getSource() == home.bAfiseaza)
show.setVisible(true);
home.setVisible(false);
model.selectData();
if (e.getSource() == add.bSalveaza)
service = add.tfServiciu.getText().toString();
password = add.tfParola.getText().toString();
model.insertData(service, password);
if (e.getSource() == add.bHome)
{
add.tfParola.setText("");
add.tfServiciu.setText("");
add.setVisible(false);
home.setVisible(true);
if (e.getSource() == show.bCopy)
model.writeTextToClipboard(tampon);
if (e.getSource() == add.bGenereaza)
String pass;
StringBuilder::appendCodePoint,
StringBuilder::append)
.toString();
add.tfParola.setText(pass);
if (e.getSource() == show.bHome)
show.setVisible(false);
home.setVisible(true);
}
}
ShowView.java
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import javax.swing.*;
JComboBox cbList;
JLabel lParola;
cbList.addItemListener(listener);
bCopy.addActionListener(listener);
bHome.addActionListener(listener);
public ShowView()
{
setLayout(new GridLayout(4,1));
add(cbList);
add(lParola);
add(bCopy);
add(bHome);
setSize(280,320);
setVisible(false);
setTitle("Afiseaza date");
TEST PROGRAM :
1. Adaugarea datelor
2. Afisarea datelor
BIBLIOGRAFIE:
1. https://www.javatpoint.com/
2. https://www.javatpoint.com/java-do-while-loop
3. https://www.javatpoint.com/java-for-loop
4. https://www.javatpoint.com/array-in-java
5. https://www.javatpoint.com/java-math